问题
Using waterline.js in sails.js (0.10.5):
I would like to create a 'where' string out of a where option object. For example, I have:
where = {
updatedAt:{">":"2015-01-08T10:00:00.000Z","<=":"2015-01-08T20:00:00.000Z"}
};
and I would like to have a generated string (similar to):
"WHERE updatedAt > '2015-01-08T10:00:00.000Z' AND updatedAt <= '2015-01-08T20:00:00.000Z'"
Is this possible? I have the feeling it should be...
回答1:
You can do date range queries using the comparison operators.
Model.find({ date: { '>': new Date('2/4/2014'), '<': new Date('2/7/2014') } })
来源:https://stackoverflow.com/questions/27852766/generate-query-string-from-where-object-in-waterline-js