node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

mongodb-scope-client

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-client

API

var scope = require('mongodb-scope-client')([endpoint], [connection]);

Parameters

  • endpoint (optional, String) ... Where the server is running [Default http://localhost:29017].
  • connection (optional, Object|mongodb-connection-model) ... MongoDB connection options [Default {}].

resource

scope.instance (opts, fn)

production

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 options
  • fn (optional, Function) ... A response callback (err, data)

scope.deployments (opts, fn)

production

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)

production

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)

production

Collection stats

Parameters
  • ns (required, String) ... A namespace string, eg #{database_name}.#{collection_name}
  • opts (optional, Object) ... Placeholder for future options
  • fn (optional, Function) ... A response callback (err, data)

scope.index (ns, name, opts, fn)

development

Index details

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

scope.document (ns, _id, opts, fn)

development

Work with a single document.

Parameters
  • ns (required, String) ... A namespace string, eg #{database_name}.#{collection_name}
  • _id (required, String) ... The document's _id value
  • opts (optional, Object) ... Placeholder for future options
  • fn (optional, Function) ... A response callback (err, data)

query

scope.find (ns, opts, fn)

production

Run a query on ns.

Parameters
  • ns (required, String) ... - A namespace string, eg #{database_name}.#{collection_name}
  • opts (optional, Object) ... - Placeholder for future options
  • fn (optional, Function) ... - A response callback (err, data)

scope.count (ns, opts, fn)

production

Run a count on ns.

Parameters
  • ns (required, String) ... A namespace string, eg #{database_name}.#{collection_name}
  • opts (optional, Object) ... - Options
  • fn (optional, Function) ... A response callback (err, data)

scope.aggregate (ns, pipeline, opts, fn)

development

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) ... - Options
  • fn (required, Function) ... A response callback (err, data)

scope.sample (ns, opts, fn)

development

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) ... - Options
  • fn (required, Function) ... - A response callback (err, data)

scope.random (ns, opts, fn)

development

Convenience to get 1 document via Client.prototype.sample.

Parameters
  • ns (required, String) ... - A namespace string, eg #{database_name}.#{collection_name}
  • opts (optional, Object) ... - Options
  • fn (required, Function) ... - A response callback (err, data)