Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-mongodb-init

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-mongodb-init - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

8

lib/indexes.js

@@ -47,3 +47,9 @@ var async = require("async"),

var coll = db.collection(indexData.collection);
coll.ensureIndex(indexData.fields, { name: indexData.name, w: 1 }, function(err){
var options = { name: indexData.name, w: 1 };
if(indexData.expireAfterSeconds !== undefined){
options.expireAfterSeconds = indexData.expireAfterSeconds;
}
coll.ensureIndex(indexData.fields, options, function(err){
if(err){

@@ -50,0 +56,0 @@ done(err);

2

package.json
{
"name": "hapi-mongodb-init",
"version": "1.0.3",
"version": "1.1.0",
"description": "initialises mongo db connections for hapi",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -163,2 +163,47 @@ describe('db-init tests', function(){

it('should pass through the expireAfterSeconds flag', function(done){
p.register(plugin, {
dbs: [{
connectionString: 'mongodb://127.0.0.1/test',
name: 'myconnection',
indexes: [
{
collection: 'mycoll',
name: 'myfield_1',
fields: {
myfield: 1
},
expireAfterSeconds: 60
}
]
}],
mongo: fakeMongo
}, function(err){
ensuredIndexes[0].names.expireAfterSeconds.should.eql(60);
done(err);
});
});
it('should not set expireAfterSeconds when it is not present in the config', function(done){
p.register(plugin, {
dbs: [{
connectionString: 'mongodb://127.0.0.1/test',
name: 'myconnection',
indexes: [
{
collection: 'mycoll',
name: 'myfield_1',
fields: {
myfield: 1
},
}
]
}],
mongo: fakeMongo
}, function(err){
(ensuredIndexes[0].names.expireAfterSeconds === undefined).should.eql(true);
done(err);
});
});
it('should not manage indexes when config is turned off', function(done){

@@ -165,0 +210,0 @@ p.register(plugin, {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc