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 = ;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 = url options;// then you can use it like Mongodb driver //insert onedb; //find db;