-
你好 我在把 twikoo 的 mongodb 转为 waline 的 mongodb data 遇到一个问题 twikoo {
"_id": "0fe806ea4beb46819f1973fac9d344f8",
"nick": "听雨轩",
"mail": "[email protected]",
"mailMd5": "2f2dc333236d17cdf545ec62a7e536bf",
"link": "www.oyhq.top",
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36",
"ip": "xxxxxxxxx",
"master": false,
"url": "/messageboard/",
"comment": "<p>膜拜大佬</p>\n",
"pid": null,
"rid": null,
"isSpam": true,
"created": {
"$numberLong": "1652415537856"
},
"updated": {
"$numberLong": "1652415539139"
}
}
waline {
"_id": {
"$oid": "61e82b939101390009d6b76e"
},
"link": "",
"mail": "[email protected]",
"nick": "test",
"pid": null,
"rid": null,
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.62",
"url": "/",
"comment": "test",
"ip": "xxxxxx",
"insertedAt": {
"$date": {
"$numberLong": "1642605458767"
}
},
"user_id": null,
"status": "approved"
} 我用 nodejs 转换 person.forEach(function(e) {
e._id = { "$oid": e._id }
e.insertedAt = {
"$date": {
"$numberLong": e.created.$numberLong
}
}
if (e.isSpam === true) {
e.status = "waiting"
} else {
e.status = "approved"
}
if (e.master === true) {
e.user_id = 'xxxxx'
} else {
e.user_id = 'null'
}
delete e.isSpam
delete e.master
delete e.created
delete e.updated
delete e.mailMd5
}); 然后通过 mongoimport 导入 |
Beta Was this translation helpful? Give feedback.
Answered by
lizheming
Jun 3, 2022
Replies: 1 comment 2 replies
-
已私聊沟通解决,Twikoo 自己生成 md5 的 id 无法直接作用到 mongodb 的 objectId 上,所以需要自己再重新映射一下。 |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
lizheming
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
已私聊沟通解决,Twikoo 自己生成 md5 的 id 无法直接作用到 mongodb 的 objectId 上,所以需要自己再重新映射一下。