Comparing version 0.0.20 to 0.0.21
@@ -45,3 +45,3 @@ 'use strict'; | ||
var cache = l2cache ? new Cache({cacheSize: 256, ttl: 300000}) : undefined; | ||
var cache = l2cache ? new Cache({cacheSize: 1024, ttl: 300000}) : undefined; | ||
@@ -55,19 +55,13 @@ var Model = function () { | ||
if (callback === undefined) { | ||
callback = options; | ||
options = {}; | ||
if (options === undefined) { | ||
callback = fields; | ||
options = {}; | ||
fields = {}; | ||
} else { | ||
callback = options; | ||
options = {}; | ||
} | ||
} | ||
odm.collection(mongoCollection, options, function (err, collection) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
collection.findOne(query, options, function (err, documentLoaded) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return callback(null, documentLoaded); | ||
}); | ||
}); | ||
odm.findOne(mongoCollection, query, fields, options, callback); | ||
}; | ||
@@ -88,20 +82,3 @@ | ||
odm.collection(mongoCollection, options, function (err, collection) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
collection.find(query, fields, options, function (err, cursor) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
cursor.toArray(function (err, documentsLoaded) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return callback(null, documentsLoaded); | ||
}); | ||
}); | ||
}); | ||
odm.find(mongoCollection, query, fields, options, callback); | ||
}; | ||
@@ -131,3 +108,3 @@ | ||
odm.collection(mongoCollection, options, function (err, collection) { | ||
odm.find(mongoCollection, {}, fields, options, function (err, documentsLoaded) { | ||
if (err) { | ||
@@ -137,18 +114,7 @@ return callback(err); | ||
collection.find({}, fields, options, function (err, cursor) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
cursor.toArray(function (err, documentsLoaded) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
if (l2cache) { | ||
putToCache(cache, mongoCollection, '', 'all', documentsLoaded); | ||
} | ||
if (l2cache) { | ||
putToCache(cache, mongoCollection, '', 'all', documentsLoaded); | ||
} | ||
return callback(null, documentsLoaded); | ||
}); | ||
}); | ||
return callback(null, documentsLoaded); | ||
}); | ||
@@ -155,0 +121,0 @@ }; |
@@ -15,2 +15,13 @@ 'use strict'; | ||
function extractOption(name, options, defaultValue) { | ||
var option = defaultValue; | ||
if (options) { | ||
if (options.hasOwnProperty(name)) { | ||
option = options[name]; | ||
delete options[name]; | ||
} | ||
} | ||
return option; | ||
} | ||
/** | ||
@@ -178,2 +189,4 @@ * @class ODM Object Document Model | ||
find: function (collection_name, query, fields, options, callback) { | ||
var stream = extractOption('stream', options, false); | ||
this.collection(collection_name, options, function (err, collection) { | ||
@@ -188,2 +201,7 @@ if (err) { | ||
} | ||
if (stream) { | ||
return callback(cursor); | ||
} | ||
cursor.toArray(callback); | ||
@@ -190,0 +208,0 @@ }); |
@@ -1069,3 +1069,3 @@ 'use strict'; | ||
var cache = l2cache ? new Cache({cacheSize: 1024, ttl: 300000}) : new Cache({cacheSize: 256, ttl: 30000}); | ||
var cache = l2cache ? new Cache({cacheSize: 1024, ttl: 300000}) : undefined; | ||
@@ -1072,0 +1072,0 @@ /** |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"engines": { | ||
@@ -11,0 +11,0 @@ "node": ">=0.4.12" |
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
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
99562
2005