Databases
MongoDB Database Management in VS Code
DBCode is a MongoDB extension for VS Code: browse collections, edit documents in a JSON editor that respects BSON types, run queries, and subscribe to change streams without leaving your editor. Install DBCode to get started, or read the MongoDB in VS Code how-to guide.
Overview
Section titled “Overview”MongoDB is a leading document-oriented NoSQL database that provides high performance, scalability, and flexibility for modern applications. Key advantages include:
- Schema flexibility: Store documents with varying structures in the same collection
- Rich query language: Powerful query capabilities including aggregation pipelines
- Horizontal scalability: Easily distribute data across multiple servers with sharding
- High availability: Built-in replication and automated failover
- Multi-model capabilities: Work with documents, time series, geospatial data, and graphs
MongoDB excels in handling large volumes of unstructured and semi-structured data, making it ideal for content management systems, mobile applications, IoT, and real-time analytics.
Supported Authentication Methods
Section titled “Supported Authentication Methods”DBCode supports MongoDB’s authentication mechanisms, selectable under the connection’s driver settings:
- Default / SCRAM-SHA-1 / SCRAM-SHA-256: Username and password (SCRAM is MongoDB’s default challenge-response auth)
- MONGODB-X509: Certificate-based authentication using a client certificate
- PLAIN (LDAP): Delegate authentication to an external LDAP service
- GSSAPI (Kerberos): Single sign-on with a Kerberos ticket, no password required. Works on Windows (via SSPI), macOS, and Linux. On macOS and Linux you first obtain a ticket for your principal (for example with
kinit user@REALM), then enter that principal as the username. Requires a Kerberos-enabled MongoDB deployment (MongoDB Enterprise).
Connecting
Section titled “Connecting”To connect to MongoDB in DBCode:
- Open the DBCode Extension: Launch Visual Studio Code and open the DBCode extension.
- Add a New Connection: Click on the “Add Connection” icon.
- Complete connection form: Select MongoDB as the database type and enter:
- Connection string URI or individual connection parameters
- Authentication mechanism and credentials
- SSL/TLS settings (if required)
- Additional connection options
- Connect: Click save to establish your connection.
- Start Managing Your Data: Explore databases, collections, and documents.
For detailed instructions on connecting to MongoDB, refer to the Connect article.
Connecting to MongoDB Atlas
Section titled “Connecting to MongoDB Atlas”MongoDB Atlas connections use the connection string from the Atlas dashboard:
- Get the connection string: In Atlas, open your cluster, click Connect, and choose Drivers. Copy the
mongodb+srv://connection string. - Add a New Connection: In DBCode, add a new MongoDB connection and paste the connection string, filling in your database user’s password.
- Connect: Click save to establish your connection.
DBCode fully supports mongodb+srv:// SRV connection strings, including TLS.
MongoDB Features in DBCode
Section titled “MongoDB Features in DBCode”DBCode enhances your MongoDB development experience with:
- JSON document editor: Visually edit and validate document structures
- Schema analysis: Understand document structure variations in collections
- BSON type support: Work with MongoDB-specific data types
- Live Streaming: Subscribe to Change Streams on any collection to watch inserts, updates, and deletes in real time. Right-click a collection and select Subscribe, or run
db.collectionName.watch()in the editor. Requires a replica set or sharded cluster
By using MongoDB with DBCode, you can efficiently develop and manage your document databases directly within Visual Studio Code.
Universal SQL
Section titled “Universal SQL”Alongside the MongoDB shell, DBCode’s query editor also accepts plain SQL. Any cell that starts with SELECT, INSERT, UPDATE, or DELETE (case-insensitive; comments above it are fine) runs as SQL against the current collection; anything else still runs as a shell command, unchanged. See Query with SQL for how the translation works across databases.
SELECT name, email, statusFROM usersWHERE status = 'active' AND signupDate >= '2026-01-01'ORDER BY signupDate DESCLIMIT 20;UPDATE usersSET status = 'inactive'WHERE email = 'jane@example.com';Supported: SELECT (columns, *, or COUNT(*)) with WHERE (comparisons, LIKE/ILIKE, IN, BETWEEN, IS [NOT] NULL, AND/OR), ORDER BY, and LIMIT/OFFSET; single-row INSERT, UPDATE, and DELETE. String literals are compared using each field’s introspected type, so date and other typed-field comparisons work as expected. Joins, GROUP BY, subqueries, functions, aliases, and parameters aren’t supported yet - each returns a clear error naming the unsupported construct instead of running silently, and queries can’t span multiple databases.
UPDATE/DELETE statements without a WHERE clause go through the same confirmation (or deny) rules as SQL connections.
Supported SQL
Section titled “Supported SQL”| Statement | Support |
|---|---|
SELECT (columns or *) | Yes |
SELECT COUNT(*) | Yes - can’t combine with ORDER BY or OFFSET |
INSERT | Single row, column list required |
UPDATE ... SET | Yes |
DELETE | Yes |
WHERE:=,!=,<>,>,>=,<,<=;LIKE(%text%,text%,%text, or plaintextfor an exact match);NOT LIKE(%text%);ILIKE(case-insensitive);IN (...);BETWEEN;IS NULL/IS NOT NULL;AND/ORwith parentheses- Ordering and paging:
ORDER BYruns server-side;LIMITandOFFSETare both supported - Comments:
--,//, and#are all recognized - String values compared against date fields use the collection’s introspected types, so a literal like
'2026-01-01'compares correctly against a real date field - String values compared against
_idautomatically match MongoDBObjectIds - Queries can’t reach another database (
db.collection) - connect to that database instead
Not yet supported: joins, GROUP BY/HAVING, DISTINCT, subqueries, CTEs, expressions or functions in SELECT, aliases, parameters, and UNION - each returns a clear error naming the construct, as noted above.
For more information about MongoDB, check out MongoDB.