我刚开始使用https://github.com/bevry/query-engine
我想知道如何在内部创建包含动态数据的查询。
这里有一个代码示例:
var query = "Berlin";
queryObject = '{"City":{$contains: "'+query+'"}}';
queryCollection.query(queryObject);
//TypeError: Object.keys called on non-object
queryObject = {"City":{$contains: "Berlin"}} ;
queryCollectionquery.(queryObject);
//working as expected
有任何想法吗?
编辑:这可以扩展到对象属性:
query = 'Berlin',
filter = 'City',
queryObject = {filter: {$contains: query}};