Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

qwebs-mongo

Package Overview
Dependencies
3
Maintainers
1
Versions
193
Issues
File Explorer

Advanced tools

qwebs-mongo

Mongo client for your Qwebs server

    0.2.34latest

Version published
Maintainers
1
Yearly downloads
4,149
decreased by-16.27%

Weekly downloads

Readme

Source

qwebs-mongo

Mongo service for Qwebs server.

NPM Build Status Coverage Status

Features

return $mongo.db.then(db => { //db is a singleton Mongo Db instance });

Add the mongo connection string in config.json

{ "mongo": { "connectionString": "mongodb://localhost:27017/database" }, }

Declare and inject $mongo service

Via route.json

{ "services": [ { "name": "$mongo", "location": "qwebs-mongo" } ] }

Or in javascript

const Qwebs = require("qwebs"); const qwebs = new Qwebs(); qwebs.inject("$mongo" ,"qwebs-mongo");

Use $mongo service

Hight level api

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); }

Low level api

/* 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 }); }); ); };

Installation

$ npm install qwebs-mongo

Test

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

Keywords

FAQs

What is qwebs-mongo?

Mongo client for your Qwebs server

Is qwebs-mongo popular?

The npm package qwebs-mongo receives a total of 2 weekly downloads. As such, qwebs-mongo popularity was classified as not popular.

Is qwebs-mongo well maintained?

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.

Last updated on 01 Nov 2017
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc