【发布时间】:2014-09-30 21:41:25
【问题描述】:
Strongloop Loopback 文档没有说明使用按位过滤器检索对象。
Example like in Loopback API documentation:
// Just an example of syntax, it does not do bitwise filter
Inventory.find({where: {status: {gt: 4}});
通过直接连接到 MongoDB,我可以做到:
// Select items with 3rd bit on in `status` field
db.inventory.find({status: {$mod: [4, 0]}});
我可以在 Loopback 模型接口后面做同样的事情吗?
在 MongoDB 文档中,他们说 $were 条件可以做同样的事情,但更昂贵:
db.inventory.find( { $where: "this.qty % 4 == 0" } )
我可以在环回中执行以下操作吗:
Inventory.find({where: "this.qty % 4 == 0"});
或者它会失败?
在我的模型中使用面向位的状态字段的整个想法是否矫枉过正?我应该只使用某种包含字符串状态列表的数组字段吗?数据库存储是不是太贵了?
谢谢
【问题讨论】:
标签: node.js mongodb bit-manipulation strongloop loopbackjs