Generate (query) string from “where” object in waterline.js

送分小仙女□ 提交于 2019-12-13 02:38:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!