0.11.0 • Published 10 years ago
mongodb-scope-client v0.11.0
mongodb-scope-client

The client to talk to mongodb-scope-server from node.js or the browser.
Want to see what it can do? Check out ./examples.
npm install --save mongodb-scope-clientAPI
var scope = require('mongodb-scope-client')([endpoint], [connection]);Parameters
endpoint(optional, String) ... Where the server is running Defaulthttp://localhost:29017.connection(optional, Object|mongodb-connection-model) ... MongoDB connection options Default{}.
resource
scope.instance (opts, fn)

Get details of the instance you're currently connected to like database_names, results of the hostInfo and buildInfo mongo commands.
Parameters
opts(optional, Object) ... Placeholder for future optionsfn(optional, Function) ... A response callback(err, data)
scope.deployments (opts, fn)

List all deployments this scout-server instance has connected to.
Parameters
opts(optional, Object) ... Placeholder for future options.fn(optional, Function) ... A response callback(err, data).
scope.database (name, opts, fn)

List collection names and stats.
Parameters
name(required, String) ... - The database name.opts(optional, Object) ... Placeholder for future options.fn(optional, Function) ... A response callback(err, data).
scope.collection (ns, opts, fn)

Collection stats
Parameters
ns(required, String) ... A namespace string, eg#{database_name}.#{collection_name}opts(optional, Object) ... Placeholder for future optionsfn(optional, Function) ... A response callback(err, data)
scope.index (ns, name, opts, fn)

Index details
Parameters
ns(required, String) ... A namespace string, eg#{database_name}.#{collection_name}name(required, String) ... The index nameopts(optional, Object) ... Placeholder for future optionsfn(optional, Function) ... A response callback(err, data)
scope.document (ns, _id, opts, fn)

Work with a single document.
Parameters
ns(required, String) ... A namespace string, eg#{database_name}.#{collection_name}_id(required, String) ... The document's_idvalueopts(optional, Object) ... Placeholder for future optionsfn(optional, Function) ... A response callback(err, data)
query
scope.find (ns, opts, fn)

Run a query on ns.
Parameters
ns(required, String) ... - A namespace string, eg#{database_name}.#{collection_name}opts(optional, Object) ... - Placeholder for future optionsfn(optional, Function) ... - A response callback(err, data)
scope.count (ns, opts, fn)

Run a count on ns.
Parameters
ns(required, String) ... A namespace string, eg#{database_name}.#{collection_name}opts(optional, Object) ... - Optionsfn(optional, Function) ... A response callback(err, data)
scope.aggregate (ns, pipeline, opts, fn)

Run an aggregation pipeline on ns.
Examples
Parameters
ns(required, String) ... A namespace string, eg#{database_name}.#{collection_name}pipeline(required, Array) ... - Agg pipeline to execute.opts(optional, Object) ... - Optionsfn(required, Function) ... A response callback(err, data)
scope.sample (ns, opts, fn)

Use resevoir sampling to get a slice of documents from a collection efficiently.
Parameters
ns(required, String) ... - A namespace string, eg#{database_name}.#{collection_name}opts(optional, Object) ... - Optionsfn(required, Function) ... - A response callback(err, data)
scope.random (ns, opts, fn)

Convenience to get 1 document via Client.prototype.sample.
Parameters
ns(required, String) ... - A namespace string, eg#{database_name}.#{collection_name}opts(optional, Object) ... - Optionsfn(required, Function) ... - A response callback(err, data)