Model.distinct引发强制转换错误,但MongoDB命令正常运行

时间:2019-05-31 23:42:12

标签: mongoose

使用mongoose@5.5.11

此命令可从mongo cli运行:

> db.pokemons.distinct('type_1')
[
    "grass",
    "fire",
    "water",
    // ...
]

但是这个Mongoose命令:

Pokemon.distinct('type_1')

失败:

Cast to ObjectId failed for value \"types\" at path \"_id\" for model \"Pokemon\"

(不知道值“类型”的来源是...)

相关架构详细信息:

const schema = new Schema({
    //...
    type_1: String,
    type_2: String,
    //...
});

0 个答案:

没有答案