clone.save(function(error) {
   assert.ifError(error);
   done();
 });
 Test.find({loc: {$near: ['30', '40'], $maxDistance: 51}}, function(err, docs) {
   db.close();
   assert.ifError(err);
   assert.equal(docs.length, 2);
   done();
 });
 Test.find({'loc.nested': {$nearSphere: ['30', '40'], $maxDistance: 1}}, function(err, docs) {
   db.close();
   assert.ifError(err);
   assert.equal(docs.length, 2);
   done();
 });
 P.findById(doc._id, function(err, doc) {
   assert.ifError(err);
   assert.strictEqual(doc.meta.date, null);
   db.close(done);
 });
 B.find({_id: b._id, boolean: {$in: [null, true]}}, function(err, doc) {
   assert.ifError(err);
   assert.ok(doc);
   assert.equal(doc[0].id, b.id);
   db.close(done);
 });
 MyModel.findById({ _id: 0 }, function(error, doc) {
   assert.ifError(error);
   assert.ok(doc);
   assert.equal(doc._id, 0);
   done();
 });
      BlogPostB.findOne({_id: {$in: [id]}}, function(err, doc) {
        assert.ifError(err);

        assert.equal(doc._id.toString(), id);
        db.close(done);
      });
        doc.save(function(err) {
          assert.ifError(err);
          assert.equal(called.post, 3);

          _done();
        });
 p.save(function(error) {
   assert.ifError(error);
   db.close(done);
 });
 S.findById(s.id, function(err, s) {
   db.close();
   assert.ifError(err);
   assert.equal(s.e[0].text, 'bye');
   done();
 });
 doc.remove(function(err5) {
   assert.ifError(err5);
   assert.equal(called.pre, 2);
   assert.equal(called.post, 2);
   db.close(done);
 });
 doc.hooksTest(function(err) {
   assert.ifError(err);
   assert.equal(steps, 2);
   done();
 });
Example #13
0
 Model.findOne({}, {nested: 1}, function(error, doc) {
   assert.ifError(error);
   assert.equal(doc.nested.name, 'val');
   db.close(done);
 });
Example #14
0
 M.find().select('_id').exec(function(err) {
   db.close();
   assert.ifError(err, err && err.stack);
   done();
 });
 exec(function(error) {
   assert.ifError(error);
   assert.equal(called, 1);
   done();
 }).
 L1.create(data, function(error) {
   assert.ifError(error);
   assert.equal(calls, 1);
   db.close(done);
 });
 Test.find({ foo: '123' }, function(error) {
   assert.ifError(error);
   assert.equal(vs.length, 1);
   assert.strictEqual(vs[0], '123');
   done();
 });
 Post.findById(p._id, function(err, p) {
   assert.ifError(err);
   assert.equal(p.comments[0].comments[0].comments[0].comments[0].title, 'c4');
   db.close(done);
 });
 exec(function(error, results) {
   assert.ifError(error);
   assert.equal(results.length, 1);
   assert.equal(results[0].name, 'Squaw Valley');
   done();
 });
 m.save(function(error, m) {
   assert.ifError(error);
   assert.equal(numListeners, m.listeners('save').length);
   db.close(done);
 });
 Nin.find({num: {$nin: [2]}}, function(err, found) {
   assert.ifError(err);
   assert.equal(found.length, 2);
   db.close(done);
 });
 Group.create({ cats: [{ name: 'Garfield' }] }, function(error, group) {
   assert.ifError(error);
   assert.ok(group.cats[0].createdAt);
   assert.ok(group.cats[0].createdAt.getTime() >= now);
   done();
 });
 B.find({title: {$type: 2}}, function(err, posts) {
   assert.ifError(err);
   assert.strictEqual(Array.isArray(posts), true);
   db.close(done);
 });
 Group.findById(group._id, function(error, group) {
   assert.ifError(error);
   assert.ok(group.cats[1].createdAt);
   assert.ok(group.cats[1].createdAt.getTime() > now);
   done();
 });
 B.find().ne('published', true).exec(function(err, doc) {
   assert.ifError(err);
   assert.ok(doc);
   assert.equal(doc[0].id, b.id);
   db.close(done);
 });
Example #26
0
 Strict.findById(doc._id, function(err, doc) {
   assert.ifError(err);
   assert.equal(doc._doc.bool, undefined);
   assert.equal(doc._doc.notInSchema, undefined);
   db.close(done);
 });
 Test.find({loc: {$nearSphere: ['30', '40']}}, function(err, docs) {
   db.close();
   assert.ifError(err);
   assert.equal(docs.length, 2);
   done();
 });
Example #28
0
 Movie.findById(super8._id, function(err, movie) {
   assert.ifError(err);
   assert.equal(movie.ratings.length, 0);
   db.close(done);
 });
 Test.find({loc: {$within: {$centerSphere: [['11', '20'], '0.4']}}}, function(err, docs) {
   db.close();
   assert.ifError(err);
   assert.equal(docs.length, 1);
   done();
 });
Example #30
0
 t.validate(function(err) {
   db.close();
   assert.ifError(err);
   done();
 });