Hello, is possible to add countAccessor to Many association? Model ``` javascript var db = config.db; var Category = db.define('category', { //properties id : Number, name : String },{ //options }); Category.hasMany("successors", {distance : Number}, Category, {reverse: 'predecessors', mergeTable: 'category_tree', mergeId: 'predecessor_id', mergeAssocId: 'successor_id'}); ``` Controller ``` javascript var Category = require('../models/Category'); exports.countSuccessors = function(req, res, next) { category_id = Number(req.params['category']); Category(category_id).countSuccessors({distance:1}, function (err, count) { res.json(count); }); } ```
Activity
dresende commentedon Mar 8, 2013
Yes, absolutely. But you might need to use the git version for a while when I implement it.
dresende commentedon Mar 8, 2013
Wait.. (so many stuff I sometimes forget about features). Try this:
Controller
Explanation: calling the
hasMany.getAccessorwithout callback makes it return aChainFindinstance. Look here:https://github.com/dresende/node-orm2/blob/master/lib/ChainFind.js#L31
czkody commentedon Mar 10, 2013
Hi,
I have just tried , but your code produced this query:
Have last versions of orm and sql-query.
dresende commentedon Mar 10, 2013
I have to look at this closer, it seems the chain is not taking care of the join option..
Changes drivers.count() to be able to pass options (related to #68)
dresende commentedon Mar 11, 2013
I think I solved it, please try the latest git.
czkody commentedon Mar 11, 2013
Hi,
Yes, you made it. Works fine. Thank you so much.