Skip to content

Commit

Permalink
Fix typo in mongodb-backend.js
Browse files Browse the repository at this point in the history
"useRawColletionNames" -> "useRawCollectionNames"
  • Loading branch information
leodutra authored Mar 14, 2017
1 parent 6766a76 commit fa0c0d6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/mongodb-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ var _ = require('lodash');
// If prefix is specified, it will be prepended to this name, like acl_resources
var aclCollectionName = 'resources';

function MongoDBBackend(db, prefix, useSingle, useRawColletionNames){
function MongoDBBackend(db, prefix, useSingle, useRawCollectionNames){
this.db = db;
this.prefix = typeof prefix !== 'undefined' ? prefix : '';
this.useSingle = (typeof useSingle !== 'undefined') ? useSingle : false;
this.useRawColletionNames = useRawColletionNames === false; // requires explicit boolean false value
this.useRawCollectionNames = useRawCollectionNames === false; // requires explicit boolean false value
}

MongoDBBackend.prototype = {
Expand Down Expand Up @@ -62,7 +62,7 @@ MongoDBBackend.prototype = {
var searchParams = (this.useSingle? {_bucketname: bucket, key:key} : {key:key});
var collName = (this.useSingle? aclCollectionName : bucket);

this.db.collection(this.prefix + removeUnsupportedChar(collName, this.useRawColletionNames),function(err,collection){
this.db.collection(this.prefix + removeUnsupportedChar(collName, this.useRawCollectionNames),function(err,collection){
if(err instanceof Error) return cb(err);
// Excluding bucket field from search result
collection.findOne(searchParams, {_bucketname: 0},function(err, doc){
Expand All @@ -85,7 +85,7 @@ MongoDBBackend.prototype = {
var searchParams = (this.useSingle? {_bucketname: bucket, key: { $in: keys }} : {key: { $in: keys }});
var collName = (this.useSingle? aclCollectionName : bucket);

this.db.collection(this.prefix + removeUnsupportedChar(collName, this.useRawColletionNames),function(err,collection){
this.db.collection(this.prefix + removeUnsupportedChar(collName, this.useRawCollectionNames),function(err,collection){
if(err instanceof Error) return cb(err);
// Excluding bucket field from search result
collection.find(searchParams, {_bucketname: 0}).toArray(function(err,docs){
Expand Down Expand Up @@ -117,7 +117,7 @@ MongoDBBackend.prototype = {
var collName = (self.useSingle? aclCollectionName : bucket);
transaction.push(function(cb){
values = makeArray(values);
self.db.collection(self.prefix + removeUnsupportedChar(collName, self.useRawColletionNames), function(err,collection){
self.db.collection(self.prefix + removeUnsupportedChar(collName, self.useRawCollectionNames), function(err,collection){
if(err instanceof Error) return cb(err);

// build doc from array values
Expand All @@ -133,7 +133,7 @@ MongoDBBackend.prototype = {
});

transaction.push(function(cb) {
self.db.collection(self.prefix + removeUnsupportedChar(collName, self.useRawColletionNames), function(err,collection){
self.db.collection(self.prefix + removeUnsupportedChar(collName, self.useRawCollectionNames), function(err,collection){
// Create index
collection.ensureIndex({_bucketname: 1, key: 1}, function(err){
if (err instanceof Error) {
Expand All @@ -159,7 +159,7 @@ MongoDBBackend.prototype = {
var collName = (self.useSingle? aclCollectionName : bucket);

transaction.push(function(cb){
self.db.collection(self.prefix + removeUnsupportedChar(collName, self.useRawColletionNames),function(err,collection){
self.db.collection(self.prefix + removeUnsupportedChar(collName, self.useRawCollectionNames),function(err,collection){
if(err instanceof Error) return cb(err);
collection.remove(updateParams,{safe:true},function(err){
if(err instanceof Error) return cb(err);
Expand All @@ -183,7 +183,7 @@ MongoDBBackend.prototype = {

values = makeArray(values);
transaction.push(function(cb){
self.db.collection(self.prefix + removeUnsupportedChar(collName, self.useRawColletionNames),function(err,collection){
self.db.collection(self.prefix + removeUnsupportedChar(collName, self.useRawCollectionNames),function(err,collection){
if(err instanceof Error) return cb(err);

// build doc from array values
Expand All @@ -200,8 +200,8 @@ MongoDBBackend.prototype = {
}
}

function removeUnsupportedChar(text, useRawColletionNames) {
if (!useRawColletionNames && (typeof text === 'string' || text instanceof String)) {
function removeUnsupportedChar(text, useRawCollectionNames) {
if (!useRawCollectionNames && (typeof text === 'string' || text instanceof String)) {
text = decodeURIComponent(text);
text = text.replace(/[/\s]/g, '_'); // replaces slashes and spaces
}
Expand Down

0 comments on commit fa0c0d6

Please sign in to comment.