假设我有一个架构
Temp.find({location.country: {$in: ['US', 'CN', 'JP']}});
location将存储一个json对象
现在我想通过这个json对象字段中的属性进行搜索,我可以使用以下查询吗?
foreach (Control control in grpBxTargetSensitivity.Controls)
{
if (control is FlowLayoutPanel && control.HasChildren)
{
foreach (Control ctrl in control.Controls)
{
if (ctrl is Panel && ctrl.HasChildren)
{
foreach (Control tbox in ctrl.Controls)
{
if (tbox is TextBox)
{
TextBox textbox = tbox as TextBox;
validData &= !string.IsNullOrWhiteSpace(textbox.Text);
}
}
}
}
}
}
答案 0 :(得分:3)
是的,您可以使用the dot notation执行此操作,只需将其括在引号内:
Temp.find({"location.country": {$in: ['US', 'CN', 'JP']}}, function(err, data) { /* ... */});