如何在猫鼬中动态查询?

时间:2019-05-13 02:58:25

标签: node.js mongodb mongoose

所以我是编程和猫鼬的新手,只是学习基础知识。 现在我得到了使用诸如

之类的条件进行动态查询的任务
query => gets all the data I input into the query in the parameter

example:

query: [ios, android] => i get all ios data, and android


query_else => gets all the data I input other than the parameter in the query

example:

query_else: [ios, android] => I got all the data OTHER ios and android

如果我尝试使用.find,则只能获取我要查找的1个特定数据,但是如果我在其中输入2个查询,则结果为[]

也许不是我要寻找的答案,而是如何考虑解决此问题,因为我缺乏关于猫鼬的知识和缺乏编码的知识,这使我陷入僵局思考

提前谢谢

活动日志集合中的帐户日志架构:

const actLogSchema = new Schema(
  {
    account_id: {
      type: Schema.Types.ObjectId,
      ref: 'account'
    },
    date_created: { type: String, default: Date.now() },
    ip: String,
    location: String,
    device: String,
    type: String,
    label: String,
    action: String,
    description: String
  },
  { versionKey: false }
);

我假设查询是{date_created,ip,位置,设备,类型,操作,标签,描述}的一部分

和query_else等于查询,但其值不同。就像上面的示例一样

0 个答案:

没有答案
相关问题