
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
hapi-mongodb-promises
Advanced tools
[ ](https://codeship.io/projects/30317) [,
settings: Optional. Provide extra settings to the connection, see documentation.
Several functions are exposed by this plugin :
find(collection, query)
: Returns a promise that resolves with the array of items matched.findOne(collection, query)
: Returns a promise that resolves with the item matched.findOneById(collection, id)
: Returns a promise that resolves with the item matched.
insert(collection, document)
: Returns a promise that resolves with the array of items added.insertOne(collection, document)
: Returns a promise that resolves with the first item added.update(collection, query, update, options)
- Returns a promise that resolves with the result of the queryThis plugin also exposes some objects :
db
: connection object to the database, if you need to run queries not available via the wrapper.Install:
npm install hapi-mongodb-promises --save
Usage example :
var Hapi = require("hapi");
var dbOpts = {
"url": "mongodb://localhost:27017/test"
};
var server = new Hapi.Server(8080);
server.pack.register({
plugin: require('hapi-mongodb-promises'),
options: dbOpts
}, function (err) {
if (err) {
console.error(err);
throw err;
}
});
server.route( {
"method" : "GET",
"path" : "/users/{id}",
"handler" : usersHandler
});
function usersHandler(request, reply) {
var mongo = request.server.plugins['hapi-mongodb-promises'];
mongo
.findOneById('users', request.params.id)
.then(reply)
.otherwise(function (err) {
reply(Hapi.error.internal('Internal MongoDB error', err));
});
};
server.start(function() {
console.log("Server started at " + server.info.uri);
});
FAQs
[ ](https://codeship.io/projects/30317) [![Coverage Status](https://coveralls.io/repos/peeter-tomberg/hapi-
The npm package hapi-mongodb-promises receives a total of 0 weekly downloads. As such, hapi-mongodb-promises popularity was classified as not popular.
We found that hapi-mongodb-promises demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.