以下是基本的用户配置文件架构
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const userprofileSchema = new Schema({
name:{type:String},
userId: { type: Number, required: true },
userName: { type: String, require: true },
avatarUrl: {type:String , default:'https://i.stack.imgur.com/dH5Lm.jpg'},
bio:{type:String},
url: String
})
module.exports = mongoose.model("userprofile",userprofileSchema);
以下是存储在 mongodb 中的文档:
{
"avatarUrl": "avatarurl",
"_id": "5edd2dfc7c213e044cc2783b",
"userId": "1000",
"name": "Sandeep Patel",
"userName": "cs-dev",
"url": "portfolioUrl",
"bio": "Work in progress!"
}
现在,当我这样做时,userPofile.findOne({userName:"value"}}它会给我结果,但如果我在数字字段上做同样的事情,即userPofile.findOne({userId:value}}结果为空。我检查了很多次。我错过了什么吗?
猫鼬版本:5.9.18
mongod 版本:3.6.12 (MMAPv1)