MongoDB:带有数组的查询字符串
是否可以查询/检查数组中的元素之一是否位于逗号分隔的字符串中?
Roles = "CRM, PRM"
CurrentRoles = [ "CRM", "Officer" ]
所以我需要检查 CurrentRoles 数组中的数组之一是否在 Roles 字符串中? 变量 (CurrentRoles) 是查询中需要使用的变量,因为它是一个动态字段,并且会根据登录者的不同而变化。
到目前为止我的查询:
{ Roles : { $in: CurrentRoles } }
Is it possible to query/check whether one of the elements in an array is in a comma separated string?
Roles = "CRM, PRM"
CurrentRoles = [ "CRM", "Officer" ]
So I need to check if one of the arrays in the CurrentRoles Array is in the Roles String?
The variable (CurrentRoles) is what needs to be used in the Query because it is a dynamic field and changes depending on who is logged in.
Query I have so far :
{ Roles : { $in: CurrentRoles } }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
mongoplayground
mongoplayground
mongoplayground
mongoplayground