mongodb-http

1.0.3 • Public • Published

Operate MongoDB by Http

Usage

  1. npm run start
    will start the web server that ready to operate mongodb, the default port is 3000
  2. use the client to call the api
    1. in the target project run npm install mongodb-http
    2. const MongoDBHttp = require('mongodb-http');
    3. const db = new MongodDBHttp('http://localhost:8080',options)

Server Sample

POST http://localhost:3000/collection/store

{
 "credentials":{
  "host": "localhost",
  "db":"britvicData"
 },
 "operation":"find",
 "args":[
  {
  "uniqueKey":"SPEEDWAY,WV RT  10 HUFF JCT,MAN,WV,25635"
  }
  ]
}

Client Sample

const MongodbHttp = require('./src/client');
const url = 'http://localhost:3000';
const options = {
  username: 'username',
  password: 'password',
  host: 'localhost',
  port: '27010',
  replicaSet: 'replicaSet',
  kms: false // whether use aws kms , default is false
};
 
const db = new MongodbHttp(url, options);
// then you can use it like Mongodb driver
 
//insert one
db.collection('test').insertOne({name: 'test'});
 
//find
 
db.collection('test').find({});

Package Sidebar

Install

npm i mongodb-http

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

91.3 kB

Total Files

18

Last publish

Collaborators

  • shawn_ljw