mongodb-http
v1.0.3
Published
http api for mongodb CRUD
Downloads
10
Readme
Operate MongoDB by Http
Usage
npm run start
will start the web server that ready to operate mongodb, the default port is3000
- use the client to call the api
- in the target project run
npm install mongodb-http
const MongoDBHttp = require('mongodb-http')
;const db = new MongodDBHttp('http://localhost:8080',options)
- in the target project run
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({});