Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongodb-data-service

Package Overview
Dependencies
Maintainers
14
Versions
686
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-data-service

MongoDB Data Service

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
416
decreased by-48.19%
Maintainers
14
Weekly downloads
 
Created
Source

mongodb-data-service

MongoDB Data Service

The data service provides an API on top of [currently] the MongoDB Node Driver and [in the future] mongodb-scout-client.

Installation

npm install --save mongodb-data-service

Usage

Instantiating the service.

  const Connection = require('mongodb-connection-model');
  const DataService = require('mongodb-data-service');

  var model = new Connection({ hostname: '127.0.0.1', port: 27018, ns: 'data-service' });
  var service = new DataService(model);

Connecting to the server.

Once the service is ready, it will also emit a DataService.Events.Readble event.

  service.connect((error) => {
    assert.equal(null, error);
  });

  function handleReadable() {
    console.log('Connected!');
  }

  service.on(DataService.Events.Readable, handleReadable);

API


  // Get information for a collection.
  service.collection('database.collection', {}, (error, result) => {
    assert.equal(null, error);
  });

  // Get a document count.
  service.count('database.collection', { a: 1 }, {}, (error, count) => {
    assert.equal(null, error);
  });

  // Get information for a database.
  service.database('database', {}, (error, result) => {
    assert.equal(null, error);
  });

  // Find documents in a collection.
  service.find('database.collection', { a: 1 }, {}, (error, documents) => {
    assert.equal(null, error);
  });

  // Get a result for a RESTful endpoint.
  service.get('/collection/database.test', {}, (error, result) => {
    assert.equal(null, error);
  });

  // Get instance details.
  service.instance({}, (error, result) => {
    assert.equal(null, error);
  });

  // Get a sample stream of documents from a collection.
  service.sample('database.collection', {});

License

Apache 2.0

Keywords

FAQs

Package last updated on 20 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc