我在用户集合中具有嵌套的属性,例如:“ 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;
}
感谢您的帮助,谢谢
您已经自己回答了。使用基于字符串的属性查询嵌套对象:
selector['cast.eyes'] = ...