Comparing version 1.0.3 to 1.0.4
@@ -58,2 +58,19 @@ var DB = require('mongodb').Db, | ||
function collectionSetup() { | ||
STORE.db.collection(options.collection || 'translations', function (err, collection) { | ||
if (collection) { | ||
collection.ensureIndex( | ||
{original: 1, locale: 1, translation: 1}, | ||
{unique: true}, | ||
function (err) { | ||
connect(err, collection); | ||
}); | ||
} else { | ||
STORE.db.createCollection(options.collection || 'translations', function (err, collection) { | ||
connect(err, collection); | ||
}); | ||
} | ||
}); | ||
} | ||
if (!_is_connected) { | ||
@@ -64,11 +81,13 @@ STORE.db.open(function (err, db) { | ||
} else { | ||
STORE.db.collection(options.collection || 'translations', function (err, collection) { | ||
if (collection) { | ||
connect(err, collection); | ||
} else { | ||
STORE.db.createCollection(options.collection || 'translations', function (err, collection) { | ||
connect(err, collection); | ||
}); | ||
} | ||
}); | ||
if (options.username && options.password) { | ||
db.authenticate(options.username, options.password, function (err) { | ||
if (err) { | ||
callback(err, null); | ||
} else { | ||
collectionSetup(); | ||
} | ||
}); | ||
} else { | ||
collectionSetup(); | ||
} | ||
} | ||
@@ -75,0 +94,0 @@ }); |
{ | ||
"name": "dialect", | ||
"description": "Translations manager for nodejs", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"author": "Pau Ramon <masylum@gmail.com>", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -54,2 +54,4 @@ ,, ,, ,, | ||
* `collection`: _translations_ | ||
* `username` (optional) | ||
* `password` (optional) | ||
* `sqlite` | ||
@@ -56,0 +58,0 @@ * `database`: _dialect.db_ |
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
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
69953
1847
181
0