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

mongodb-data-service

Package Overview
Dependencies
Maintainers
0
Versions
698
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.0.0-next-7e3e53be10eb2396c2c3f47d0f4bb8b7175d7c31
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
increased by700%
Maintainers
0
Weekly downloads
 
Created
Source

mongodb-data-service

MongoDB Data Service: an API on top of the MongoDB Node Driver

Installation

npm install --save mongodb-data-service

Usage

Creating a new service instance

const { connect } = require('mongodb-data-service');

// ...

const service = await connect({
  driverUrl: 'mongodb://localhost:27018/data-service',
});

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', {});

Instance Details

collections

[
  {
    _id: 'admin.system.version',
    name: 'system.version',
    database: 'admin',
    readonly: false,
    collation: null,
    type: 'collection',
    view_on: undefined,
    pipeline: undefined,
  },
  {
    _id: 'config.system.sessions',
    name: 'system.sessions',
    database: 'config',
    readonly: false,
    collation: null,
    type: 'collection',
    view_on: undefined,
    pipeline: undefined,
  },
  {
    _id: 'data-service.test',
    name: 'test',
    database: 'data-service',
    readonly: false,
    collation: null,
    type: 'collection',
    view_on: undefined,
    pipeline: undefined,
  },
  {
    _id: 'data-service.system.views',
    name: 'system.views',
    database: 'data-service',
    readonly: false,
    collation: null,
    type: 'collection',
    view_on: undefined,
    pipeline: undefined,
  },
  {
    _id: 'data-service.myView',
    name: 'myView',
    database: 'data-service',
    readonly: true,
    collation: null,
    type: 'view',
    view_on: 'test',
    pipeline: [{ $project: { a: 0 } }],
  },
  {
    _id: 'local.startup_log',
    name: 'startup_log',
    database: 'local',
    readonly: false,
    collation: null,
    type: 'collection',
    view_on: undefined,
    pipeline: undefined,
  },
];

Contributing

Running Tests

npm test

Keywords

FAQs

Package last updated on 29 Aug 2024

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