Aller au contenu
← Retour aux projets

Tabularis Mongodb Plugin

#tabularis-mongodb-plugin

Build & Release Discord

A MongoDB plugin for Tabularis, the lightweight database management tool.

This plugin enables Tabularis to connect to any MongoDB instance and provides collection browsing, document-level CRUD, index management, and aggregation pipeline execution through a JSON-RPC 2.0 over stdio interface.

Discord - Join our discord server and chat with the maintainers.

#Table of Contents

#Features

  • Connection — Connect through legacy host/port fields or a full mongodb:// or mongodb+srv:// URI, including MongoDB Atlas, replica sets, multi-host deployments, and driver options.
  • Collection Browsing — List databases, collections, and infer schema by sampling documents.
  • Schema Inference — Automatically detects field names and BSON types by sampling up to 100 documents per collection.
  • Index Inspection — List collection indexes with name, columns, uniqueness, and primary flag.
  • Query Execution — Run read (find, findOne, aggregate, count) and write (insertOne, updateMany, deleteMany, createIndex, drop, and more) commands using MongoDB shell syntax.
  • Inline Editing — Insert, update, and delete documents directly from the Tabularis data grid, keeping the BSON type each field already uses.
  • ObjectId Handling — Automatically converts string primary key values to ObjectId when filtering by _id.
  • DDL-equivalent Generation — Generates MongoDB shell commands for createCollection, createIndex, $rename, and more.
  • Cross-platform — Pre-built binaries for Linux (x86_64, aarch64), macOS (x86_64, aarch64), and Windows (x86_64).

#Connection Configuration

The plugin supports two connection formats:

  • Full URI — Pass connection_uri with either the mongodb:// or mongodb+srv:// scheme. The URI is forwarded to the official MongoDB driver, preserving Atlas DNS discovery, multiple hosts, replica-set settings, TLS settings, authentication options, and other query parameters. When present, the full URI takes precedence over legacy fields.
  • Legacy fields — Existing host, port, user, password, and database connection fields remain supported. The plugin assembles them into a standard MongoDB URI, so existing Tabularis connections continue to work.

The selected database can be supplied by the request schema, by the connection's database field (as either a string or an array), or by the URI path. If none is provided, the plugin uses admin.

Sending connection_uri requires the Tabularis host support introduced by TabularisDB/tabularis#495. Older Tabularis versions can continue to use the legacy connection fields.

#Supported MongoDB Data Types

Category Types
Numeric Int32, Int64, Double, Decimal128
String String
Date/Time Date
Binary Binary
Other Boolean, ObjectId, Array, Object

#Installation

#Automatic (via Tabularis)

If your version of Tabularis supports plugin management, the MongoDB plugin can be installed directly from the application.

#Manual Installation

  1. Download the latest release for your platform from the Releases page.
  2. Extract the archive.
  3. Copy tabularis-mongodb-plugin (or tabularis-mongodb-plugin.exe on Windows) and .tabularium into the Tabularis plugins directory:
OS Plugins Directory
Linux ~/.local/share/tabularis/plugins/mongodb/
macOS ~/Library/Application Support/com.debba.tabularis/plugins/mongodb/
Windows %APPDATA%\com.debba.tabularis\plugins\mongodb\
  1. Restart Tabularis.

#How It Works

The plugin is a standalone Rust binary that communicates with Tabularis through JSON-RPC 2.0 over stdio:

  1. Tabularis spawns the plugin as a child process.
  2. Requests are sent as newline-delimited JSON-RPC messages to the plugin's stdin.
  3. The plugin connects to MongoDB using the official Rust driver and writes responses to stdout.

Connection state is pooled per URI — the same Client instance is reused for all operations within a session.

#Query Syntax

The execute_query method accepts two formats:

#MongoDB Shell Syntax (recommended)

// Find documents
db.users.find({"age": {"$gt": 18}})

// Find with projection
db.users.find({"active": true}, {"name": 1, "email": 1})

// Find first match
db.orders.findOne({"status": "pending"})

// Aggregation pipeline
db.orders.aggregate([
  {"$match": {"status": "shipped"}},
  {"$group": {"_id": "$customer_id", "total": {"$sum": "$amount"}}}
])

// Count documents
db.users.countDocuments({"role": "admin"})

// Write documents
db.users.insertOne({"name": "Ada", "age": 36})
db.users.updateMany({"active": true}, {"$set": {"role": "member"}})
db.users.deleteOne({"name": "Ada"})

// Collection and index management
db.createCollection("orders")
db.users.createIndex({"email": 1}, {"name": "idx_email", "unique": true})
db.users.dropIndex("idx_email")
db.orders.drop()

Arguments are parsed as strict JSON, so keys and string values need double quotes.

#SQL-like (for table browsing)

When Tabularis browses a collection it sends SELECT * FROM collection_name. The plugin automatically converts this to find({}) on the named collection. Deleting a collection from the explorer sends DROP TABLE collection_name, which the plugin runs as a collection drop.

#Supported Operations

Method Description
test_connection Ping the MongoDB server
get_databases List all databases
get_schemas Returns [] (MongoDB has no schemas)
get_tables List collections in the current database
get_columns Infer fields and types by sampling documents
get_foreign_keys Returns [] (no FK constraints in MongoDB)
get_indexes List indexes for a collection
execute_query Run shell-syntax read and write commands with pagination
insert_record Insert a new document
update_record Update a single field, located by the primary key map sent by the host
delete_record Delete a document, located by the primary key map sent by the host
get_schema_snapshot Full schema dump (all collections + inferred columns)
get_all_columns_batch Inferred columns for all collections
get_all_foreign_keys_batch Returns {}
get_create_table_sql Generates db.createCollection(...)
get_add_column_sql Returns a schemaless note
get_alter_column_sql Generates $rename update command
get_create_index_sql Generates db.collection.createIndex(...)
get_create_foreign_key_sql Returns a not-supported note
drop_index Drops a collection index

#Building from Source

#Prerequisites

  • Rust (edition 2021)
  • A running MongoDB instance (for integration tests)

#Build

cargo build --release

The binary will be located at target/release/tabularis-mongodb-plugin.

#Install Locally

A convenience script is provided to build and copy the plugin to the Tabularis plugins directory:

./sync.sh

#Development

#Testing the Plugin

Two development binaries are included:

Connectivity test (requires a local MongoDB on port 27017):

cargo run --bin test

For a custom or authenticated server, load MONGODB_URI into the environment through your shell's secret-manager integration before running the command. Do not print or commit the URI.

Simulated Tabularis integration test (spawns the plugin and sends JSON-RPC requests via stdio):

cargo run --bin test_plugin

#Manual JSON-RPC test via shell

echo '{"jsonrpc":"2.0","method":"test_connection","params":{"params":{"host":"localhost","port":27017,"database":"test"}},"id":1}' \
  | ./target/release/tabularis-mongodb-plugin

#Tech Stack

  • Language: Rust (edition 2021)
  • Database driver: mongodb v3 (official async Rust driver)
  • Serialization: serde + serde_json + bson
  • Async runtime: tokio
  • Protocol: JSON-RPC 2.0 over stdio

#Changelog

#License

Apache License 2.0

Nouvelle version disponible.