mongoscope-client
v0.2.8
Published
shush
Downloads
19
Maintainers
Readme
mongoscope-client
A client for wielding mongoscope like the hammer of thor.
Examples are available in ./examples
and as a Codepen Collection.
npm install --save mongoscope-client
API
var mongoscope = require('mongoscope-client')([opts]);
Parameters
opts
(optional, Object) ...scope
(String) ... Where mongoscope-server is running defaulthttp://localhost:29017
seed
(String) ... Hostport of mongodb instance defaultlocalhost:27017
auth
(Object) ... Auth spec default{}
resource
Create, read, update and destroy databases, collections, documents and indices.
mongoscope.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)
mongoscope.deployments(opts, fn)
List all deployments this mongoscope instance has connected to.
Parameters
opts
(optional, Object) ... Placeholder for future optionsfn
(optional, Function) ... A response callback(err, data)
mongoscope.database(name, opts, fn)
List collection names and stats.
Parameters
name
(required, String)opts
(optional, Object) ... Placeholder for future optionsfn
(optional, Function) ... A response callback(err, data)
mongoscope.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)
mongoscope.operation(_id, opts, fn)
A currently running operation.
Parameters
_id
(required, Number)opts
(optional, Object) ... Placeholder for future optionsfn
(optional, Function) ... A response callback(err, data)
mongoscope.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)
mongoscope.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_id
valueopts
(optional, Object) ... Placeholder for future optionsfn
(optional, Function) ... A response callback(err, data)
mongoscope.tunnel()
Open an ssh tunnel to securely connect to a remote host.
rt
Run MongoDB query operations, including virtual operations such as collection sampling.
mongoscope.top(opts, fn)
Capture the deltas of top over opts.interval
ms.
Parameters
opts
(optional, Object) ... Placeholder for future optionsinterval
(Number) ... Duration of sample in ms default1000
fn
(required, Function) ... A response callback(err, data)
mongoscope.log(opts, fn)
A structured view of the ramlog.
Parameters
opts
(optional, Object) ... Placeholder for future optionsfn
(required, Function) ... A response callback(err, data)
mongoscope.ops(opts, fn)
List currently running operations.
Parameters
opts
(optional, Object) ... Placeholder for future optionsfn
(optional, Function) ... A response callback(err, data)
mongoscope.sharding(opts, fn)
Get the sharding info for the cluster the instance you're connected
to is a member of, similar to the printShardingStatus()
helper function
in the mongo shell.
Examples
Parameters
opts
(optional, Object) ... Placeholder for future optionsfn
(required, Function) ... A response callback(err, data)
mongoscope.replication(opts, fn)
View current state of all members and oplog details.
Parameters
opts
(optional, Object) ... Placeholder for future optionsfn
(required, Function) ... A response callback(err, data)
mongoscope.oplog(opts, fn)
Get oplog entries.
Parameters
opts
(optional, Object) ...since
(Number) ... Epoch time lower bounds defaultDate.now() - 1000 * 60
filters
(Array) ... List of tuples({key}, {regex})
default[]
fn
(required, Function) ... A response callback(err, data)
mongoscope.analytics(group, opts, fn)
Get or stream a group of analytics, which can be any of one durability, operations, memory, replication, network or indexes.
Parameters
group
(required, String)opts
(optional, Object) ... Placeholder for future optionsfn
(optional, Function) ... A response callback(err, data)
query
Run MongoDB query operations, including virtual operations such as collection sampling.
mongoscope.find(ns, opts, fn)
Run a query on db.collection
.
Parameters
ns
(required, String) ... A namespace string, eg#{database_name}.#{collection_name}
opts
(optional, Object) ... Placeholder for future optionsquery
(Object) ... default{}
limit
(Number) ... default10
, max 200skip
(Number) ... default 0explain
(Boolean) ... Return explain instead of documents defaultfalse
sort
(Object) ...{key: (1|-1)}
spec defaultnull
fields
(Object) ... @todooptions
(Object) ... @todobatchSize
(Number) ... @todo
fn
(optional, Function) ... A response callback(err, data)
mongoscope.count(ns, opts, fn)
Run a count on db.collection
.
Parameters
ns
(required, String) ... A namespace string, eg#{database_name}.#{collection_name}
opts
(optional, Object) ...query
(Object) ... default{}
limit
(Number) ... default10
, max 200skip
(Number) ... default 0explain
(Boolean) ... Return explain instead of documents defaultfalse
sort
(Object) ...{key: (1|-1)}
spec defaultnull
fields
(Object) ... @todooptions
(Object) ... @todobatchSize
(Number) ... @todo
fn
(optional, Function) ... A response callback(err, data)
mongoscope.aggregate(ns, pipeline, opts, fn)
Run an aggregation pipeline on db.collection
.
Examples
Parameters
ns
(required, String) ... A namespace string, eg#{database_name}.#{collection_name}
pipeline
(required, Array)opts
(optional, Object) ...explain
(Boolean) ... @todoallowDiskUse
(Boolean) ... @todocursor
(Object) ... @todo
fn
(required, Function) ... A response callback(err, data)
mongoscope.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) ...size
(Number) ... The number of samples to obtain default5
query
(Object) ... Restrict the sample to a subset default{}
fn
(required, Function) ... A response callback(err, data)
mongoscope.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) ...query
(Object) ... Restrict the sample to a subset default{}
fn
(required, Function) ... A response callback(err, data)
mongoscope.workingSet(opts, fn)
Working set size estimator.
Parameters
opts
(optional, Object)fn
(required, Function) ... A response callback(err, data)