mongodb-scope-client
A client for mongodb-scope-server that works in the browser or a server.
Last updated 5 years ago by imlucas .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mongodb-scope-client 
SYNC missed versions from official npm registry.

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)

Current Tags

  • 0.11.0                                ...           latest (5 years ago)

5 Versions

  • 0.11.0                                ...           5 years ago
  • 0.10.2                                ...           5 years ago
  • 0.10.1                                ...           5 years ago
  • 0.10.0                                ...           5 years ago
  • 0.8.0                                ...           5 years ago

Copyright 2014 - 2016 © taobao.org |