Modules@robinpath/mongo

@robinpath/mongo

0.1.1Public

MongoDB client with find, insert, update, delete, aggregation pipeline, indexing, and connection management

@robinpath/mongo

MongoDB client with find, insert, update, delete, aggregation pipeline, indexing, and connection management

Category Functions Auth License

Why use this module?

The mongo module lets you:

  • Find documents
  • Find one document
  • Insert one document
  • Insert multiple documents
  • Update one document

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/mongo

Quick Start

1. Set up credentials

mongo.connect {"uri": "mongodb://localhost:27017", "database": "mydb"}

2. Find documents

mongo.find "users" {"age": {"$gt": 18}} {"limit": 10}

Available Functions

FunctionDescription
mongo.connectConnect to MongoDB
mongo.findFind documents
mongo.findOneFind one document
mongo.insertOneInsert one document
mongo.insertManyInsert multiple documents
mongo.updateOneUpdate one document
mongo.updateManyUpdate many documents
mongo.deleteOneDelete one document
mongo.deleteManyDelete many documents
mongo.aggregateRun aggregation pipeline
mongo.countCount documents
mongo.distinctGet distinct values
mongo.collectionsList collections
mongo.createIndexCreate index
mongo.objectIdGenerate or parse ObjectId
mongo.closeClose connection
mongo.closeAllClose all connections

Examples

Find documents

mongo.find "users" {"age": {"$gt": 18}} {"limit": 10}

Find one document

mongo.findOne "users" {"email": "alice@example.com"}

Insert one document

mongo.insertOne "users" {"name": "Alice", "age": 30}

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/mongo";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  mongo.connect {"uri": "mongodb://localhost:27017", "database": "mydb"}
  mongo.find "users" {"age": {"$gt": 18}} {"limit": 10}
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.1latestyesterday
Install
$ robinpath install @robinpath/mongo
Version0.1.1
LicenseMIT
Unpacked Size5.5 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

data