用户集合中的流星易搜索嵌套字段

时间:2020-06-07 01:06:04

标签: mongodb meteor selector

我的用户集合中有嵌套的属性,例如:“ users.cast.eyes”

如何使用轻松搜索选择器构面搜索那些对象?

/*This is not working, because "eyes" is a nested property*/
if (options.search.props.eyes) {
  selector.eyes = options.search.props.eyes;
}

/*This is not working, I'm getting a not such property error*/
if (options.search.props.eyes) {
  selector.cast.eyes = options.search.props.eyes;
}

感谢您的帮助,谢谢

1 个答案:

答案 0 :(得分:0)

您已经自己回答了。使用基于字符串的属性查询嵌套对象:

selector['cast.eyes'] = ...
相关问题