从“where"生成(查询)字符串waterline.js 中的对象 [英] Generate (query) string from "where" object in waterline.js
本文介绍了从“where"生成(查询)字符串waterline.js 中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在sails.js (0.10.5) 中使用waterline.js:
Using waterline.js in sails.js (0.10.5):
我想从 where 选项对象中创建一个 'where' 字符串.例如,我有:
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...
推荐答案
您可以使用比较运算符进行日期范围查询.
You can do date range queries using the comparison operators.
Model.find({ date: { '>': new Date('2/4/2014'), '<': new Date('2/7/2014') } })
这篇关于从“where"生成(查询)字符串waterline.js 中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文