hapi-mongodb-init
Advanced tools
Comparing version 3.3.0 to 4.0.0
@@ -16,3 +16,3 @@ module.exports = function(grunt) { | ||
}, | ||
mochaTest:{ | ||
mochaTest: { | ||
options: { | ||
@@ -19,0 +19,0 @@ reporter: 'spec' |
@@ -42,3 +42,3 @@ var indexes = require("./indexes"), | ||
else { | ||
db[config.name] = conn; | ||
db[config.name] = conn.db(config.dbName); | ||
} | ||
@@ -58,3 +58,3 @@ | ||
conn.command({ismaster: true}, function(err, d){ | ||
conn.db(config.dbName).command({ismaster: true}, function(err, d){ | ||
if(err){ | ||
@@ -64,3 +64,3 @@ return callback(err); | ||
manageIndexes(conn, config, plugin, callback); | ||
manageIndexes(conn.db(config.dbName), config, plugin, callback); | ||
}); | ||
@@ -67,0 +67,0 @@ }); |
{ | ||
"name": "hapi-mongodb-init", | ||
"version": "3.3.0", | ||
"version": "4.0.0", | ||
"description": "initialises mongo db connections for hapi", | ||
@@ -28,2 +28,3 @@ "main": "index.js", | ||
"grunt-mocha-test": "^0.12.7", | ||
"mocha": "^7.1.2", | ||
"should": "^7.0.2" | ||
@@ -36,4 +37,4 @@ }, | ||
"peerDependencies": { | ||
"mongodb": "^2.0.0" | ||
"mongodb": "^3.0.0" | ||
} | ||
} |
@@ -9,2 +9,3 @@ #Hapi mongodb-init | ||
Unfortunately thanks to the breaking changes introduced in the 2.x driver then hapi-mongodb-init@3.x.x will work with mongodb@2.x.x. | ||
Breaking changes are introduced in the 3.x driver too then hapi-mongodb-init@4.x.x will work with mongodb@3.x.x. | ||
@@ -24,2 +25,3 @@ To initialise: | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [ | ||
@@ -94,2 +96,3 @@ { | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
manageIndexes: false | ||
@@ -96,0 +99,0 @@ }], |
@@ -28,25 +28,27 @@ describe('db-init tests', function(){ | ||
db: function(dbname) { | ||
return dbname; | ||
}, | ||
collection: function(){ | ||
return { | ||
indexes: function(cb){ | ||
return cb(null, actualIndexes); | ||
}, | ||
ensureIndex: function(x, y, callback){ | ||
if(x.error === 1){ | ||
return callback(new Error("ensureIndex has exploded")); | ||
dbname, | ||
collection: function(){ | ||
return { | ||
indexes: function(cb){ | ||
return cb(null, actualIndexes); | ||
}, | ||
ensureIndex: function(x, y, callback){ | ||
if(x.error === 1){ | ||
return callback(new Error("ensureIndex has exploded")); | ||
} | ||
ensuredIndexes.push({ fields: x, names: y }); | ||
return callback(); | ||
}, | ||
dropIndex: function(z, callback){ | ||
droppedIndexes.push(z); | ||
return callback(); | ||
} | ||
} | ||
ensuredIndexes.push({ fields: x, names: y }); | ||
return callback(); | ||
}, | ||
dropIndex: function(z, callback){ | ||
droppedIndexes.push(z); | ||
return callback(); | ||
} | ||
} | ||
command: function(c, callback){ callback(); } | ||
}; | ||
}, | ||
on: function(event, fn){}, | ||
command: function(c, callback){ callback(); } | ||
}); | ||
@@ -66,2 +68,3 @@ } | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [] | ||
@@ -80,2 +83,3 @@ }], | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [] | ||
@@ -102,2 +106,3 @@ }], | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [] | ||
@@ -138,2 +143,3 @@ }], | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [], | ||
@@ -192,4 +198,4 @@ connectionOptions: { | ||
}, function(err){ | ||
p.db('collection1').should.eql('db1'); | ||
p.db('collection2').should.eql('db2'); | ||
p.db('collection1').dbname.should.eql('db1'); | ||
p.db('collection2').dbname.should.eql('db2'); | ||
done(err); | ||
@@ -205,2 +211,3 @@ }); | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [] | ||
@@ -234,2 +241,3 @@ }], | ||
connectionString: 'mongodb://127.0.0.1/test', | ||
dbName: 'mydatabase', | ||
indexes: [ | ||
@@ -258,2 +266,3 @@ { | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [ | ||
@@ -281,2 +290,3 @@ { | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [ | ||
@@ -306,2 +316,3 @@ { | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [ | ||
@@ -330,2 +341,3 @@ { | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [ | ||
@@ -353,2 +365,3 @@ { | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
manageIndexes: false | ||
@@ -368,2 +381,3 @@ }], | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [] | ||
@@ -373,3 +387,2 @@ }], | ||
}, function(err){ | ||
p.db('myconnection').should.not.eql(undefined); | ||
@@ -386,2 +399,3 @@ done(err); | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [] | ||
@@ -400,2 +414,3 @@ }], | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [{ | ||
@@ -417,2 +432,3 @@ collection: 'error', | ||
name: 'myconnection', | ||
dbName: 'mydatabase', | ||
indexes: [{ | ||
@@ -434,3 +450,4 @@ collection: 'error', | ||
connectionString: 'mongodb://127.0.0.1', | ||
name: 'myconnection' | ||
name: 'myconnection', | ||
dbName: 'mydatabase' | ||
}], | ||
@@ -437,0 +454,0 @@ mongo: fakeMongo |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
24009
593
102
6
11