Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

p-odm

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-odm - npm Package Compare versions

Comparing version 0.0.20 to 0.0.21

66

lib/document.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc