Registry / devops / mongodb-ace-mode

mongodb-ace-mode

JSON →
library2.0.1jsnpmunverified

Provides MongoDB syntax highlighting, autocompletion, and query support for the ACE code editor. Version 2.0.1 is the latest stable release. It is part of the MongoDB Compass project and is primarily maintained for use within that ecosystem. It offers specialized mode for JSON-like MongoDB queries and aggregation pipelines, with support for BSON types and shell syntax. Low release cadence; primarily bug fixes.

npm install mongodb-ace-mode
INSTALL
IMPORT
SIG · MONGODB-ACE-MODE
M
mongodb-ace-mode
devopsjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MongoMode
import { MongoMode } from 'mongodb-ace-mode'
const MongoMode = require('mongodb-ace-mode').MongoMode
ESM-only; use named import.
default import
import ace from 'ace-builds'; import mode from 'mongodb-ace-mode'
import MongoMode from 'mongodb-ace-mode'
No default export. Must import named export.
require()
const { MongoMode } = require('mongodb-ace-mode')
const MongoMode = require('mongodb-ace-mode')
CommonJS destructuring required.

Sets up an ACE editor with MongoDB syntax highlighting and inserts a sample query.

import ace from 'ace-builds'; import { MongoMode } from 'mongodb-ace-mode'; const editor = ace.edit('editor'); editor.session.setMode(new MongoMode()); editor.setValue(`db.users.find({ age: { $gt: 25 } })`, -1);
Debug
Known issues
breakingVersion 2.0.0 dropped support for CommonJS-style require without destructuring.
fix
Use import { MongoMode } from 'mongodb-ace-mode' or const { MongoMode } = require('mongodb-ace-mode')
affects: >=2.0.0
deprecatedMode constructor may be deprecated in future versions in favor of ace.config.setModule.
fix
Monitor changelog for migration to ace config API.
affects: >=1.0.0
gotchaThe mode depends on ace-builds being loaded first; expects ace global or imported separately.
fix
Ensure ace editor is imported before using the mode.
affects: all
Errors
Common errors & fixes
TypeError: ace.edit is not a function
ACE editor library not imported properly.
fix
Install and import ace-builds: import ace from 'ace-builds';
Cannot find module 'mongodb-ace-mode'
Package not installed or typo in package name.
fix
Run 'npm install mongodb-ace-mode' and check package.json for correct name.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Amazon
1
Resources
mongodb-ace-mode — npm install mongodb-ace-mode · libregistry