Reputation: 325
Why when use sort in sails, don't works proyections.
Command.find({},{parameter:true, value: true, _id: false, finalDate:true}).sort('finalDate ASC').exec(function(error, cmd){}
Upvotes: 1
Views: 128
Reputation: 325
Here is answer
When you use Sort() this disable proyection.
When you use Waterline you are not interacting directly with the sails-mongo driver. Waterline is an adapter agnostic abstraction that allows adapters to be built using a specific interface.
The current find method only takes a criteria object and not a projection object. This is because the find method in Waterline must work with not only sails-mongo but also sails-mysql, sails-postgresql, sails-redis, etc.
In the next Waterline release, 0.10, I want to introduce a select option to the query builder to allow this sort of thing to be accomplished across all adapters.
In the meantime if you want projections you have access to the direct mongo driver by using the native method:
// Grab an instance of the mongo-driver
User.native(function(err, collection) {
// Execute any query that works with the mongo js driver
collection.find(criteria, projection).sort(sort).toArray(function(err, docs) {
console.log(users);
});
});
Upvotes: 0
Reputation: 2051
Where did you find projections
documentations? AFAIK, projections
is not available in Waterline.
Upvotes: 2