【发布时间】:2020-06-07 21:01:28
【问题描述】:
我的用户集合中有嵌套属性,例如:“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;
}
感谢任何帮助,谢谢
【问题讨论】:
-
使用 MongoDB,您可以使用点符号查询文档的嵌套文件,看看this part of the docs