Socket
Socket
Sign inDemoInstall

mongoose

Package Overview
Dependencies
Maintainers
0
Versions
883
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

7

History.md
1.0.16 / 2011-02-18
===================
* Added $nin as another whitelisted $conditional for SchemaArray [brian]
* Changed #with to #where [brian]
* Added ability to use $in conditional with Array types [brian]
1.0.15 / 2011-02-18

@@ -3,0 +10,0 @@ ===================

3

lib/mongoose/drivers/node-mongodb-native/objectid.js

@@ -14,2 +14,4 @@

var ObjectIdToString = ObjectId.toString.bind(ObjectId);
module.exports = exports = ObjectId;

@@ -35,3 +37,4 @@ /**

exports.toString = function(oid){
if (!arguments.length) return ObjectIdToString();
return oid.toHexString();
};

2

lib/mongoose/index.js

@@ -256,3 +256,3 @@

exports.version = '1.0.15';
exports.version = '1.0.16';

@@ -259,0 +259,0 @@ /**

@@ -463,12 +463,12 @@

/**
* `with` enables a very nice sugary api for doing your queries.
* `where` enables a very nice sugary api for doing your queries.
* For example, instead of writing:
* User.find({age: {$gte: 21, $lte: 65}}, callback);
* we can instead write more readably:
* User.with('age').gte(21).lte(65);
* User.where('age').gte(21).lte(65);
* Moreover, you can also chain a bunch of these together like:
* User
* .with('age').gte(21).lte(65)
* .with('name', /^b/i) // All names that begin with b or B
* .with('friends').slice(10);
* .where('age').gte(21).lte(65)
* .where('name', /^b/i) // All names that begin where b or B
* .where('friends').slice(10);
* @param {String} path

@@ -480,5 +480,5 @@ * @param {Object} val (optional)

Model.with = function (path, val) {
Model.where = function (path, val) {
var q = new Query().bind(this);
return q.with.apply(q, arguments);
return q.where.apply(q, arguments);
};

@@ -485,0 +485,0 @@

@@ -6,5 +6,5 @@ var Query = require('./query');

NamedScope.prototype.with = function () {
NamedScope.prototype.where = function () {
var q = this.query || (this.query = new Query());
q.with.apply(q, arguments);
q.where.apply(q, arguments);
return q;

@@ -11,0 +11,0 @@ };

@@ -156,12 +156,12 @@ var utils = require('./utils')

/**
* `with` enables a very nice sugary api for doing your queries.
* `where` enables a very nice sugary api for doing your queries.
* For example, instead of writing:
* User.find({age: {$gte: 21, $lte: 65}}, callback);
* we can instead write more readably:
* User.with('age').gte(21).lte(65);
* User.where('age').gte(21).lte(65);
* Moreover, you can also chain a bunch of these together like:
* User
* .with('age').gte(21).lte(65)
* .with('name', /^b/i) // All names that begin with b or B
* .with('friends').slice(10);
* .where('age').gte(21).lte(65)
* .where('name', /^b/i) // All names that begin where b or B
* .where('friends').slice(10);
* @param {String} path

@@ -173,3 +173,3 @@ * @param {Object} val (optional)

Query.prototype.with = function (path, val) {
Query.prototype.where = function (path, val) {
var conds;

@@ -275,3 +275,3 @@ if (arguments.length === 2) {

// if you're migrating to usernames from user id numbers:
// query.with('user_id').in([4444, 'brian']);
// query.where('user_id').in([4444, 'brian']);

@@ -281,4 +281,4 @@ // TODO "immortal" cursors

// To be used idiomatically with Query#box and Query#center
['within', '$within'].forEach( function (getter) {
// To be used idiomatically where Query#box and Query#center
['wherein', '$wherein'].forEach( function (getter) {
Object.defineProperty(Query.prototype, getter, {

@@ -298,3 +298,3 @@ get: function () {

var conds = this._conditions[path] || (this._conditions[path] = {});
conds['$within'] = { '$box': [val.ll, val.ur] };
conds['$wherein'] = { '$box': [val.ll, val.ur] };
return this;

@@ -310,3 +310,3 @@ };

var conds = this._conditions[path] || (this._conditions[path] = {});
conds['$within'] = { '$center': [val.center, val.radius] };
conds['$wherein'] = { '$center': [val.center, val.radius] };
return this;

@@ -596,3 +596,3 @@ };

* If there is an error, the callback handles it. Otherwise,
* we just invoke the callback without passing it an error.
* we just invoke the callback whereout passing it an error.
*

@@ -620,3 +620,3 @@ * @param {Function} callback fn(err)

* Casts the query, sends the remove command to
* mongodb with the query contents, and then
* mongodb where the query contents, and then
* invokes a callback upon receiving the command

@@ -623,0 +623,0 @@ * result.

@@ -108,2 +108,8 @@ /**

}
, '$in': function (val) {
return this.cast(val);
}
, '$nin': function (val) {
return this.cast(val);
}
};

@@ -110,0 +116,0 @@ SchemaArray.prototype.castForQuery = function ($conditional, val) {

{
"name": "mongoose"
, "description": "Mongoose MongoDB ORM"
, "version": "1.0.15"
, "version": "1.0.16"
, "author": "Guillermo Rauch <guillermo@learnboost.com>"

@@ -6,0 +6,0 @@ , "keywords": ["mongodb", "mongoose", "orm", "data", "datastore", "nosql"]

@@ -142,3 +142,3 @@

'test that query is executed with a callback for findOne': function () {
'test that query is executed where a callback for findOne': function () {
var db = start()

@@ -304,3 +304,3 @@ , BlogPostB = db.model('BlogPostB', collection)

'test finding documents with an array that contains one specific member': function () {
'test finding documents where an array that contains one specific member': function () {
var db = start()

@@ -429,3 +429,3 @@ , BlogPostB = db.model('BlogPostB', collection);

// GH-199
'test find queries with $in cast the values within the array': function () {
'test find queries where $in cast the values wherein the array': function () {
var db = start()

@@ -450,3 +450,3 @@ , BlogPostB = db.model('BlogPostB', collection);

// GH-232
'test find queries with $nin cast the values within the array': function () {
'test find queries where $nin cast the values wherein the array': function () {
var db = start()

@@ -474,3 +474,3 @@ , NinSchema = new Schema({

'test for findById with partial initialization': function () {
'test for findById where partial initialization': function () {
var db = start()

@@ -530,3 +530,3 @@ , BlogPostB = db.model('BlogPostB', collection)

'test find with subset of fields, excluding _id': function () {
'test find where subset of fields, excluding _id': function () {
var db = start()

@@ -545,3 +545,3 @@ , BlogPostB = db.model('BlogPostB', collection);

'test for find with partial initialization': function () {
'test for find where partial initialization': function () {
var db = start()

@@ -644,6 +644,26 @@ , BlogPostB = db.model('BlogPostB', collection)

'test querying via $which with a string': function () {
'test querying if an array contains one of multiple members $in a set': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection);
var post = new BlogPostB();
post.tags.push('football');
post.save( function (err) {
should.strictEqual(err, null);
BlogPostB.findOne({tags: {$in: ['football', 'baseball']}}, function (err, doc) {
should.strictEqual(err, null);
doc._id.should.eql(post._id);
db.close();
});
});
},
'test querying via $which where a string': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection);
BlogPostB.create({ title: 'Steve Jobs', author: 'Steve Jobs'}, function (err, created) {

@@ -661,3 +681,3 @@ should.strictEqual(err, null);

'test querying via $which with a function': function () {
'test querying via $which where a function': function () {
var db = start()

@@ -681,3 +701,3 @@ , BlogPostB = db.model('BlogPostB', collection);

// TODO Won't pass until we fix materialization/raw data assymetry
'test find with $exists': function () {
'test find where $exists': function () {
var db = start()

@@ -740,3 +760,3 @@ , ExistsSchema = new Schema({

'test finding with $elemMatch': function () {
'test finding where $elemMatch': function () {
var db = start()

@@ -762,3 +782,3 @@ , BlogPostB = db.model('BlogPostB', collection)

'test finding with $mod': function () {
'test finding where $mod': function () {
var db = start()

@@ -780,3 +800,3 @@ , Mod = db.model('Mod', 'mods_' + random());

'test finding with $not': function () {
'test finding where $not': function () {
var db = start()

@@ -798,3 +818,3 @@ , Mod = db.model('Mod', 'mods_' + random());

'test finding with $or': function () {
'test finding where $or': function () {
var db = start()

@@ -820,3 +840,3 @@ , Mod = db.model('Mod', 'mods_' + random());

'test finding with $ne': function () {
'test finding where $ne': function () {
var db = start()

@@ -895,5 +915,5 @@ , Mod = db.model('Mod', 'mods_' + random());

BlogPostB.create({numbers: [-1,-2,-3,-4]}, function (err, withoutZero) {
BlogPostB.create({numbers: [-1,-2,-3,-4]}, function (err, whereoutZero) {
should.strictEqual(err, null);
BlogPostB.create({numbers: [0,-1,-2,-3,-4]}, function (err, withZero) {
BlogPostB.create({numbers: [0,-1,-2,-3,-4]}, function (err, whereZero) {
should.strictEqual(err, null);

@@ -913,9 +933,9 @@ BlogPostB.find({numbers: {$all: [-1, -2, -3, -4]}}, function (err, found) {

'test finding documents with an array of a certain $size': function () {
'test finding documents where an array of a certain $size': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection);
BlogPostB.create({numbers: [1,2,3,4,5,6,7,8,9,10]}, function (err, withoutZero) {
BlogPostB.create({numbers: [1,2,3,4,5,6,7,8,9,10]}, function (err, whereoutZero) {
should.strictEqual(err, null);
BlogPostB.create({numbers: [11,12,13,14,15,16,17,18,19,20]}, function (err, withZero) {
BlogPostB.create({numbers: [11,12,13,14,15,16,17,18,19,20]}, function (err, whereZero) {
should.strictEqual(err, null);

@@ -937,3 +957,3 @@ BlogPostB.create({numbers: [1,2,3,4,5,6,7,8,9,10,11]}, function (err, found) {

'test finding documents with an array with the $slice operator': function () {
'test finding documents where an array where the $slice operator': function () {
var db = start()

@@ -1024,3 +1044,3 @@ , BlogPostB = db.model('BlogPostB', collection);

BlogPostB
.with('meta.visitors').gt(99).lt(301)
.where('meta.visitors').gt(99).lt(301)
.sort('meta.visitors', -1)

@@ -1027,0 +1047,0 @@ .find( function (err, found) {

@@ -1,8 +0,8 @@

//Query.prototype.with(criteria, callback)
//Query.prototype.with(path, val, callback)
//Query.prototype.where(criteria, callback)
//Query.prototype.where(path, val, callback)
//
//UserNS.namedScope({
// twenties: Query.with('age').gte(20).lt(30)
// , male: Query.with('gender', 'male')
// , lastLogin: Query.with('lastLogin').get(+new Date - (24 * 3600 * 1000))
// twenties: Query.where('age').gte(20).lt(30)
// , male: Query.where('gender', 'male')
// , lastLogin: Query.where('lastLogin').get(+new Date - (24 * 3600 * 1000))
//});

@@ -44,7 +44,7 @@ //

UserNSSchema.namedScope('olderThan', function (age) {
return this.with('age').gt(age);
return this.where('age').gt(age);
});
UserNSSchema.namedScope('youngerThan', function (age) {
return this.with('age').lt(age);
return this.where('age').lt(age);
});

@@ -54,8 +54,8 @@

UserNSSchema.namedScope('male').with('gender', 'male');
UserNSSchema.namedScope('male').where('gender', 'male');
UserNSSchema.namedScope('female').with('gender', 'female');
UserNSSchema.namedScope('female').where('gender', 'female');
UserNSSchema.namedScope('active', function () {
return this.with('lastLogin').gte(+new Date - _24hours)
return this.where('lastLogin').gte(+new Date - _24hours)
});

@@ -65,3 +65,3 @@

// TODO Add in tests for using named scopes with findOne, update, remove
// TODO Add in tests for using named scopes where findOne, update, remove
module.exports = {

@@ -207,3 +207,3 @@ 'basic named scopes should work, for find': function () {

should.strictEqual(null, err);
UserNS.female.with('age').gt(99).findOne( function (err, found) {
UserNS.female.where('age').gt(99).findOne( function (err, found) {
db.close();

@@ -215,3 +215,3 @@ should.strictEqual(err, null);

);
}
},
// 'using chained named scopes in a find': function () {

@@ -218,0 +218,0 @@ // var db = start()

@@ -104,9 +104,9 @@

'test setting a condition via with': function () {
'test setting a condition via where': function () {
var query = new Query();
query.with('name', 'guillermo');
query.where('name', 'guillermo');
query._conditions.should.eql({name: 'guillermo'});
},
'test Query#gte with 2 arguments': function () {
'test Query#gte where 2 arguments': function () {
var query = new Query();

@@ -117,3 +117,3 @@ query.gte('age', 18);

'test Query#gt with 2 arguments': function () {
'test Query#gt where 2 arguments': function () {
var query = new Query();

@@ -124,3 +124,3 @@ query.gt('age', 17);

'test Query#lte with 2 arguments': function () {
'test Query#lte where 2 arguments': function () {
var query = new Query();

@@ -131,3 +131,3 @@ query.lte('age', 65);

'test Query#lt with 2 arguments': function () {
'test Query#lt where 2 arguments': function () {
var query = new Query();

@@ -138,23 +138,23 @@ query.lt('age', 66);

'test Query#gte with 1 argument': function () {
'test Query#gte where 1 argument': function () {
var query = new Query();
query.with("age").gte(18);
query.where("age").gte(18);
query._conditions.should.eql({age: {$gte: 18}});
},
'test Query#gt with 1 argument': function () {
'test Query#gt where 1 argument': function () {
var query = new Query();
query.with("age").gt(17);
query.where("age").gt(17);
query._conditions.should.eql({age: {$gt: 17}});
},
'test Query#lte with 1 argument': function () {
'test Query#lte where 1 argument': function () {
var query = new Query();
query.with("age").lte(65);
query.where("age").lte(65);
query._conditions.should.eql({age: {$lte: 65}});
},
'test Query#lt with 1 argument': function () {
'test Query#lt where 1 argument': function () {
var query = new Query();
query.with("age").lt(66);
query.where("age").lt(66);
query._conditions.should.eql({age: {$lt: 66}});

@@ -165,3 +165,3 @@ },

var query = new Query();
query.with("age").lt(66).gt(17);
query.where("age").lt(66).gt(17);
query._conditions.should.eql({age: {$lt: 66, $gt: 17}});

@@ -173,8 +173,8 @@ },

query
.with("age").lt(66)
.with("height").gt(5);
.where("age").lt(66)
.where("height").gt(5);
query._conditions.should.eql({age: {$lt: 66}, height: {$gt: 5}});
},
'test Query#ne with 2 arguments': function () {
'test Query#ne where 2 arguments': function () {
var query = new Query();

@@ -185,5 +185,5 @@ query.ne('age', 21);

'test Query#gte with 1 argument': function () {
'test Query#gte where 1 argument': function () {
var query = new Query();
query.with("age").ne(21);
query.where("age").ne(21);
query._conditions.should.eql({age: {$ne: 21}});

@@ -194,3 +194,3 @@ },

var query = new Query();
query.with('age').notEqualTo(21);
query.where('age').notEqualTo(21);
query._conditions.should.eql({age: {$ne: 21}});

@@ -203,3 +203,3 @@

'test Query#in with 2 arguments': function () {
'test Query#in where 2 arguments': function () {
var query = new Query();

@@ -210,9 +210,9 @@ query.in('age', [21, 25, 30]);

'test Query#in with 1 argument': function () {
'test Query#in where 1 argument': function () {
var query = new Query();
query.with("age").in([21, 25, 30]);
query.where("age").in([21, 25, 30]);
query._conditions.should.eql({age: {$in: [21, 25, 30]}});
},
'test Query#in with a non-array value not via with': function () {
'test Query#in where a non-array value not via where': function () {
var query = new Query();

@@ -223,9 +223,9 @@ query.in('age', 21);

'test Query#in with a non-array value via with': function () {
'test Query#in where a non-array value via where': function () {
var query = new Query();
query.with('age').in(21);
query.where('age').in(21);
query._conditions.should.eql({age: {$in: 21}});
},
'test Query#nin with 2 arguments': function () {
'test Query#nin where 2 arguments': function () {
var query = new Query();

@@ -236,9 +236,9 @@ query.nin('age', [21, 25, 30]);

'test Query#nin with 1 argument': function () {
'test Query#nin where 1 argument': function () {
var query = new Query();
query.with("age").nin([21, 25, 30]);
query.where("age").nin([21, 25, 30]);
query._conditions.should.eql({age: {$nin: [21, 25, 30]}});
},
'test Query#nin with a non-array value not via with': function () {
'test Query#nin where a non-array value not via where': function () {
var query = new Query();

@@ -249,9 +249,9 @@ query.nin('age', 21);

'test Query#nin with a non-array value via with': function () {
'test Query#nin where a non-array value via where': function () {
var query = new Query();
query.with('age').nin(21);
query.where('age').nin(21);
query._conditions.should.eql({age: {$nin: 21}});
},
'test Query#mod not via with, with [a, b] param': function () {
'test Query#mod not via where, where [a, b] param': function () {
var query = new Query();

@@ -262,3 +262,3 @@ query.mod('age', [5, 2]);

'test Query#mod not via with, with a and b params': function () {
'test Query#mod not via where, where a and b params': function () {
var query = new Query();

@@ -269,27 +269,27 @@ query.mod('age', 5, 2);

'test Query#mod via with, with [a, b] param': function () {
'test Query#mod via where, where [a, b] param': function () {
var query = new Query();
query.with("age").mod([5, 2]);
query.where("age").mod([5, 2]);
query._conditions.should.eql({age: {$mod: [5, 2]}});
},
'test Query#mod via with, with a and b params': function () {
'test Query#mod via where, where a and b params': function () {
var query = new Query();
query.with("age").mod(5, 2);
query.where("age").mod(5, 2);
query._conditions.should.eql({age: {$mod: [5, 2]}});
},
'test Query#near via with, with [lat, long] param': function () {
'test Query#near via where, where [lat, long] param': function () {
var query = new Query();
query.with('checkin').near([40, -72]);
query.where('checkin').near([40, -72]);
query._conditions.should.eql({checkin: {$near: [40, -72]}});
},
'test Query#near via with, with lat and long params': function () {
'test Query#near via where, where lat and long params': function () {
var query = new Query();
query.with('checkin').near(40, -72);
query.where('checkin').near(40, -72);
query._conditions.should.eql({checkin: {$near: [40, -72]}});
},
'test Query#near not via with, with [lat, long] param': function () {
'test Query#near not via where, where [lat, long] param': function () {
var query = new Query();

@@ -300,3 +300,3 @@ query.near('checkin', [40, -72]);

'test Query#near not via with, with lat and long params': function () {
'test Query#near not via where, where lat and long params': function () {
var query = new Query();

@@ -307,39 +307,39 @@ query.near('checkin', 40, -72);

'test Query#within.box not via with': function () {
'test Query#wherein.box not via where': function () {
var query = new Query();
query.within.box('gps', {ll: [5, 25], ur: [10, 30]});
query._conditions.should.eql({gps: {$within: {$box: [[5, 25], [10, 30]]}}});
query.wherein.box('gps', {ll: [5, 25], ur: [10, 30]});
query._conditions.should.eql({gps: {$wherein: {$box: [[5, 25], [10, 30]]}}});
},
'test Query#within.box via with': function () {
'test Query#wherein.box via where': function () {
var query = new Query();
query.with('gps').within.box({ll: [5, 25], ur: [10, 30]});
query._conditions.should.eql({gps: {$within: {$box: [[5, 25], [10, 30]]}}});
query.where('gps').wherein.box({ll: [5, 25], ur: [10, 30]});
query._conditions.should.eql({gps: {$wherein: {$box: [[5, 25], [10, 30]]}}});
},
'test Query#within.center not via with': function () {
'test Query#wherein.center not via where': function () {
var query = new Query();
query.within.center('gps', {center: [5, 25], radius: 5});
query._conditions.should.eql({gps: {$within: {$center: [[5, 25], 5]}}});
query.wherein.center('gps', {center: [5, 25], radius: 5});
query._conditions.should.eql({gps: {$wherein: {$center: [[5, 25], 5]}}});
},
'test Query#within.center not via with': function () {
'test Query#wherein.center not via where': function () {
var query = new Query();
query.with('gps').within.center({center: [5, 25], radius: 5});
query._conditions.should.eql({gps: {$within: {$center: [[5, 25], 5]}}});
query.where('gps').wherein.center({center: [5, 25], radius: 5});
query._conditions.should.eql({gps: {$wherein: {$center: [[5, 25], 5]}}});
},
'test Query#exists with 0 arguments via with': function () {
'test Query#exists where 0 arguments via where': function () {
var query = new Query();
query.with("username").exists();
query.where("username").exists();
query._conditions.should.eql({username: {$exists: true}});
},
'test Query#exists with 1 argument via with': function () {
'test Query#exists where 1 argument via where': function () {
var query = new Query();
query.with("username").exists(false);
query.where("username").exists(false);
query._conditions.should.eql({username: {$exists: false}});
},
'test Query#exists with 1 argument not via with': function () {
'test Query#exists where 1 argument not via where': function () {
var query = new Query();

@@ -350,3 +350,3 @@ query.exists('username');

'test Query#exists with 1 argument not via with': function () {
'test Query#exists where 1 argument not via where': function () {
var query = new Query();

@@ -359,9 +359,9 @@ query.exists("username", false);

'test Query#all via with': function () {
'test Query#all via where': function () {
var query = new Query();
query.with('pets').all(['dog', 'cat', 'ferret']);
query.where('pets').all(['dog', 'cat', 'ferret']);
query._conditions.should.eql({pets: {$all: ['dog', 'cat', 'ferret']}});
},
'test Query#all not via with': function () {
'test Query#all not via where': function () {
var query = new Query();

@@ -380,9 +380,9 @@ query.all('pets', ['dog', 'cat', 'ferret']);

'test Query#size via with': function () {
'test Query#size via where': function () {
var query = new Query();
query.with('collection').size(5);
query.where('collection').size(5);
query._conditions.should.eql({collection: {$size: 5}});
},
'test Query#size not via with': function () {
'test Query#size not via where': function () {
var query = new Query();

@@ -393,47 +393,47 @@ query.size('collection', 5);

'test Query#slice via with, with just positive limit param': function () {
'test Query#slice via where, where just positive limit param': function () {
var query = new Query();
query.with('collection').slice(5);
query.where('collection').slice(5);
query._fields.should.eql({collection: {$slice: 5}});
},
'test Query#slice via with, with just negative limit param': function () {
'test Query#slice via where, where just negative limit param': function () {
var query = new Query();
query.with('collection').slice(-5);
query.where('collection').slice(-5);
query._fields.should.eql({collection: {$slice: -5}});
},
'test Query#slice via with, with [skip, limit] param': function () {
'test Query#slice via where, where [skip, limit] param': function () {
var query = new Query();
query.with('collection').slice([14, 10]); // Return the 15th through 25th
query.where('collection').slice([14, 10]); // Return the 15th through 25th
query._fields.should.eql({collection: {$slice: [14, 10]}});
},
'test Query#slice via with, with skip and limit params': function () {
'test Query#slice via where, where skip and limit params': function () {
var query = new Query();
query.with('collection').slice(14, 10); // Return the 15th through 25th
query.where('collection').slice(14, 10); // Return the 15th through 25th
query._fields.should.eql({collection: {$slice: [14, 10]}});
},
'test Query#slice via with, with just positive limit param': function () {
'test Query#slice via where, where just positive limit param': function () {
var query = new Query();
query.with('collection').slice(5);
query.where('collection').slice(5);
query._fields.should.eql({collection: {$slice: 5}});
},
'test Query#slice via with, with just negative limit param': function () {
'test Query#slice via where, where just negative limit param': function () {
var query = new Query();
query.with('collection').slice(-5);
query.where('collection').slice(-5);
query._fields.should.eql({collection: {$slice: -5}});
},
'test Query#slice via with, with the [skip, limit] param': function () {
'test Query#slice via where, where the [skip, limit] param': function () {
var query = new Query();
query.with('collection').slice([14, 10]); // Return the 15th through 25th
query.where('collection').slice([14, 10]); // Return the 15th through 25th
query._fields.should.eql({collection: {$slice: [14, 10]}});
},
'test Query#slice via with, with the skip and limit params': function () {
'test Query#slice via where, where the skip and limit params': function () {
var query = new Query();
query.with('collection').slice(14, 10); // Return the 15th through 25th
query.where('collection').slice(14, 10); // Return the 15th through 25th
query._fields.should.eql({collection: {$slice: [14, 10]}});

@@ -443,3 +443,3 @@ },

'test Query#slice not via with, with just positive limit param': function () {
'test Query#slice not via where, where just positive limit param': function () {
var query = new Query();

@@ -450,3 +450,3 @@ query.slice('collection', 5);

'test Query#slice not via with, with just negative limit param': function () {
'test Query#slice not via where, where just negative limit param': function () {
var query = new Query();

@@ -457,3 +457,3 @@ query.slice('collection', -5);

'test Query#slice not via with, with [skip, limit] param': function () {
'test Query#slice not via where, where [skip, limit] param': function () {
var query = new Query();

@@ -464,3 +464,3 @@ query.slice('collection', [14, 10]); // Return the 15th through 25th

'test Query#slice not via with, with skip and limit params': function () {
'test Query#slice not via where, where skip and limit params': function () {
var query = new Query();

@@ -471,3 +471,3 @@ query.slice('collection', 14, 10); // Return the 15th through 25th

'test Query#elemMatch not via with': function () {
'test Query#elemMatch not via where': function () {
var query = new Query();

@@ -478,7 +478,7 @@ query.elemMatch('comments', {author: 'bnoguchi', votes: {$gte: 5}});

'test Query#elemMatch not via with, with block notation': function () {
'test Query#elemMatch not via where, where block notation': function () {
var query = new Query();
query.elemMatch('comments', function (elem) {
elem.with('author', 'bnoguchi')
elem.with('votes').gte(5);
elem.where('author', 'bnoguchi')
elem.where('votes').gte(5);
});

@@ -488,13 +488,13 @@ query._conditions.should.eql({comments: {$elemMatch: {author: 'bnoguchi', votes: {$gte: 5}}}});

'test Query#elemMatch via with': function () {
'test Query#elemMatch via where': function () {
var query = new Query();
query.with('comments').elemMatch({author: 'bnoguchi', votes: {$gte: 5}});
query.where('comments').elemMatch({author: 'bnoguchi', votes: {$gte: 5}});
query._conditions.should.eql({comments: {$elemMatch: {author: 'bnoguchi', votes: {$gte: 5}}}});
},
'test Query#elemMatch via with, with block notation': function () {
'test Query#elemMatch via where, where block notation': function () {
var query = new Query();
query.with('comments').elemMatch(function (elem) {
elem.with('author', 'bnoguchi')
elem.with('votes').gte(5);
query.where('comments').elemMatch(function (elem) {
elem.where('author', 'bnoguchi')
elem.where('votes').gte(5);
});

@@ -505,3 +505,3 @@ query._conditions.should.eql({comments: {$elemMatch: {author: 'bnoguchi', votes: {$gte: 5}}}});

'test Query#$where with a function arg': function () {
'test Query#$where where a function arg': function () {
var query = new Query();

@@ -515,3 +515,3 @@ function filter () {

'test Query#where with a javascript string arg': function () {
'test Query#where where a javascript string arg': function () {
var query = new Query();

@@ -518,0 +518,0 @@ query.$where('this.lastName === this.firstName');

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