janez89 / mongoose-materialized

mongoose materialized plugin
59 stars 22 forks source link

Wwhy sorting is not working in getArrayTree #21

Closed burakkilic closed 8 years ago

burakkilic commented 8 years ago

Hi;

I have the following code:

doc.getArrayTree({
        sort: {
            order: 1
        }
    }, function(err, tree) {
        if (err) res.json(err);
        return res.json({
            type: true,
            data: tree
        });
    });

Order is not changes if I retrieve data like that. Where am I wrong?

burakkilic commented 8 years ago

Update:

I commented out

// sort by depth desc /map.sort(function (a, b) { return b.depth - a.depth; });/

in schema.static('ToArrayTree', function (docs, fields)

and now it is working.