查询语法。我想从一个集合中选择两个字段值的数据作为子集。
我的一些尝试如下;
"{ $and: { "gene" : "A1CF"}, { "tissue" : "LUNG"}}"
Error: Invalid JSON object: { $and: { "gene" : "A1CF"}, { "tissue" : "LUNG"}}
"{ { "gene" : "A1CF"}, { "tissue" : "LUNG"}}"
Error: Invalid JSON object: { { "gene" : "A1CF"}, { "tissue" : "LUNG"}}
在这个例子中,我正在查询基因和组织; A1CF和肺。
我的JSON对象是;
{
"_id" : ObjectId("5d139e3817ddc2d8750e0f13"),
"gene" : "A1CF",
"driver_genename" : "ERBB2",
"target_genename" : "A1CF",
"wilcox_p" : 0.00777647226632117,
"effect_size" : 0.772727272727273,
"zdiff" : -1.0725469683635,
"tissue" : "BREAST"
}
{
"_id" : ObjectId("5d139e3817ddc2d8750e0f14"),
"gene" : "A1CF",
"driver_genename" : "AFF4",
"target_genename" : "A1CF",
"wilcox_p" : 0.0120300751879699,
"effect_size" : 0.907407407407407,
"zdiff" : -0.0983195839378545,
"tissue" : "LARGE_INTESTINE"
}
答案 0 :(得分:0)
$and
MonogoDB运算符需要一个数组,即
.find({ $and: [{ "gene" : "A1CF"}, { "tissue" : "LUNG"}] });
有关详细信息,请访问:https://docs.mongodb.com/manual/reference/operator/query/and/
如何:
您应该能够执行此操作,结果应该相同:
.find({ "gene" : "A1CF", "tissue" : "LUNG" });