Mongoose查找数组元素是否在另一个数组中

时间:2018-03-18 21:43:37

标签: javascript node.js mongodb mongoose

如何检查数组中的元素是否属于Mongoose中的另一个数组。 例如,我有一份文件:

{"_id":"","username":"","password":"","email":"","image":"1-81-14.svg","dob":"","marital_status":"","phone":"","categories":["catering_services","legal_services","computer_programmers","rentals","fashion_designers","education"]}

和同一集合的另一个文件:

{"_id":"","username":"","password":"","email":"","image":"1-81-14.svg","dob":"","marital_status":"","phone":"","categories":["computer_programmers","rentals","fashion_designers","education", "music"]}

如何检查第一个文档的categories节点中至少有一个数组元素是否属于第二个文档中的数组

0 个答案:

没有答案