1
0
Fork 0

fixed collection prefix for users and sessions

This commit is contained in:
Frank Celler 2014-10-20 10:59:54 +02:00
parent 13a45f56f5
commit a3892fb672
2 changed files with 6 additions and 3 deletions

View File

@ -7,4 +7,4 @@
if (db._collection(usersName) === null) {
db._create(usersName, {isSystem: true});
}
}());
}());

View File

@ -194,12 +194,15 @@ function extendContext (context, app, root) {
var cp = context.collectionPrefix;
var cname = "";
if (cp !== "") {
if (cp === "_") {
cname = "_";
}
else if (cp !== "") {
cname = cp + "_";
}
context.collectionName = function (name) {
var replaced = (cname + name).replace(/[^a-zA-Z0-9]/g, '_').replace(/(^_+|_+$)/g, '').substr(0, 64);
var replaced = cname + name.replace(/[^a-zA-Z0-9]/g, '_').replace(/(^_+|_+$)/g, '').substr(0, 64);
if (replaced.length === 0) {
throw new Error("Cannot derive collection name from '" + name + "'");