How to sort a document query by a document field
I'm just getting started with Massive, so forgive my noobness...
I have a projects
table filed with project documents that were stored using the standard saveDoc()
method. I would like to retrieve a limited list of projects sorted by an updatedAt
field that is within the document body.
I've tried things like this without luck:
db.find({}, {order: 'body->>updatedAt', limit: 10}, callback);
What is the best process to do this (or do I need to store the updatedAt field outside the body as a standard date column)?
On a related matter, is it possible to only include only some of the fields from the document in the result set (like we can use the columns
option for normal queries), or is that something that has to be done after the query?
Thanks.