qwebs-mongo
Advanced tools
Mongo client for your Qwebs server
Weekly downloads
Readme
Mongo service for Qwebs server.
return $mongo.db.then(db => {
//db is a singleton Mongo Db instance
});
{
"mongo": {
"connectionString": "mongodb://localhost:27017/database"
},
}
{
"services": [
{ "name": "$mongo", "location": "qwebs-mongo" }
]
}
const Qwebs = require("qwebs");
const qwebs = new Qwebs();
qwebs.inject("$mongo" ,"qwebs-mongo");
const { CRUD } = require("qwebs-mongo");
class Api extends CRUD {
constructor($mongo) {
super("collectionName", $mongo);
};
/* manage skip and limit as querystring */
httpStream(request, response) {
request.mongo = { //define mongo query, options,...
options: {
limit: parseInt(request.query.limit),
skip: parseInt(request.query.skip)
}
}
return super.httpStream(request, response);
}
/* no extend -> custom implementation */
class Api {
constructor($mongo) {
this.$mongo = $mongo;
};
httpStream(request, response) {
return this.$mongo.db.then(db => {
const limit = parseInt(request.query.limit);
const skip = parseInt(request.query.skip);
const stream = db.collection("collectionName").find({}).limit(limit).skip(skip).stream();
return response.send({ request: request, stream: stream });
});
);
};
$ npm install qwebs-mongo
To run our tests, clone the qwebs-mongo repo and install the dependencies.
$ git clone https://github.com/BenoitClaveau/qwebs-mongo --depth 1
$ cd qwebs-mongo
$ npm install
$ mongod --dbpath ./data/db
$ node.exe "../node_modules/mocha/bin/mocha" tests
Mongo client for your Qwebs server
The npm package qwebs-mongo receives a total of 2 weekly downloads. As such, qwebs-mongo popularity was classified as not popular.
We found that qwebs-mongo demonstrated a not healthy version release cadence and project activity. It has 1 open source maintainer collaborating on the project.