Features
Custom Actions
Create JavaScript custom actions to automate operations on MongoDB documents in Mingo.
Custom Actions let you define reusable JavaScript functions that operate on selected documents. They appear in the document context menu for quick access.
Creating a Custom Action
Define a custom action with:
- Name — a descriptive label shown in the context menu
- Icon — a Font Awesome icon (e.g.
fas fa-check) - Color — visual identifier in the menu
- Code — an async JavaScript function
Example: Set Status to Active
async function () {
await CurrentCollection.updateOne(
{ _id: CurrentDocument._id },
{ $set: { status: "active" } }
)
return "Status updated"
}
Example: Archive Document
async function () {
const confirmed = await MingoConfirm("Archive this document?")
if (!confirmed) return "Cancelled"
await ArchivedItems.insertOne(CurrentDocument)
await CurrentCollection.deleteOne({ _id: CurrentDocument._id })
return "Document archived"
}
Available Variables
- db — current MongoDB database connection
- CurrentCollection — reference to the current collection
- CurrentDocument — the selected document
- ObjectId — MongoDB ObjectId wrapper
- dayjs — date manipulation library
- _ (underscore) — Lodash utility library
- Collection names — direct references (e.g.
Users,Orders) - MingoConfirm() — show a confirmation dialog
- MingoPrompt() — show a prompt dialog
- MingoOpen() — open a document or collection
In Projects, you can access collections from all connected databases using camelCase names.
Using Custom Actions
- Right-click a document in the Documents view
- Find your custom action in the context menu
- Click to execute it on the selected document
Managing Actions
Custom actions are stored per collection. You can edit, rename, and delete actions through the Actions section.