Node.js 猫鼬籽
我正在使用mongoose种子模块为我的数据库添加一些初始数据,这些数据在json文件中,并没有按照文件的顺序进行种子设定Node.js 猫鼬籽,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我正在使用mongoose种子模块为我的数据库添加一些初始数据,这些数据在json文件中,并没有按照文件的顺序进行种子设定 [{ "model": "User", "documents": [ { "name": "User1", "email": "user1@gmail.com" }, { "name": "User2", "email": "user2@gmail.com" }, { "name": "User3", "e
[{
"model": "User",
"documents": [
{
"name": "User1",
"email": "user1@gmail.com"
},
{
"name": "User2",
"email": "user2@gmail.com"
},
{
"name": "User3",
"email": "user3@gmail.com"
}
]
}]
在我的数据库中,数据是按随机顺序播种的,与user1、user2、user3不同。使用具有智能参考支持的最终播种器。为什么它们被插入数据库的顺序很重要?因为ID。我有mongoose自动增值插件,我依靠id在其他模型和文档中引用。