猫鼬:在数组上建立索引时提示错误

时间:2019-03-04 21:08:42

标签: mongodb mongoose mongodb-indexes

我有一个像猫鼬的模型

const OffersSchema = new Schema({ 
    storeIdList : [{
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Stores',
        required: true
    }],
    status: {
        type: String, 
        required: true, 
        enum: ['INACTIVE', 'ACTIVE', 'SUSPENDED'],
        default: 'INACTIVE'
    }
   // ...some other fields...
})
OffersSchema.index({"storeIdList":1,"status":1,"_id":-1})

然后我要查询:

let index = {"storeIdList":1,"status":1,"_id":-1}
let docs = await Offers.find({}).hint(index)

我得到一个错误“计划返回错误:错误提示”。 我在做什么错了?

0 个答案:

没有答案