From f99dbb75f32c607e67184ab0cc1df1f145c21bea Mon Sep 17 00:00:00 2001 From: Tape Date: Wed, 13 Nov 2013 17:08:50 -0600 Subject: [PATCH] Include merge options in chain find count --- lib/ChainFind.js | 4 +++- test/integration/model-find-chain.js | 29 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/ChainFind.js b/lib/ChainFind.js index 25dd07fc..a9bcb730 100644 --- a/lib/ChainFind.js +++ b/lib/ChainFind.js @@ -67,7 +67,9 @@ function ChainFind(Model, opts) { return this; }, count: function (cb) { - opts.driver.count(opts.table, opts.conditions, {}, function (err, data) { + opts.driver.count(opts.table, opts.conditions, { + merge: opts.merge + }, function (err, data) { if (err || data.length === 0) { return cb(err); } diff --git a/test/integration/model-find-chain.js b/test/integration/model-find-chain.js index 83638c5e..fb80917d 100644 --- a/test/integration/model-find-chain.js +++ b/test/integration/model-find-chain.js @@ -194,6 +194,35 @@ describe("Model.find() chaining", function() { return done(); }); }); + + // TODO: Make this code Mongo compatible? + // it("should account for associations", function (done) { + // var Bob = new Person({ + // name: "Bob", + // surname: "Smith", + // age: 20 + // }); + // var Jill = new Person({ + // name: "Jill", + // surname: "Smith", + // age: 20 + // }); + + // Person.find({ name: "John" }, function (err, John) { + // should.equal(err, null); + // John = John[0]; + + // John.setParents([ Bob, Jill ], function (err) { + // should.equal(err, null); + // Person(John.id).getParents({ name: "Bob" }).count(function (err, count) { + // should.equal(err, null); + // count.should.equal(1); + + // return done(); + // }); + // }); + // }); + // }); }); describe(".first()", function () {