mongoose-exists检查一个数组的元素是否在集合中已存在

场景:检查数据库某集合中是否存在name为“测试”的数据是否存在

Modle.exists({ name: "测试" })  //返回值类型为boolean

场景:检查数据库某集合中是否已存在name为"测试1"、“测试2”、“测试3”......的元素

const arr=[{name: "测试1"},{name: "测试2"},{name: "测试3"}....]
const isExist=Modle.exists({ $or: arr })
原文地址:https://www.cnblogs.com/ellen-mylife/p/14591592.html