if(i==posts_json.length){console.log('Object ID not found in posts');process.exit(2);}
constdata=posts_json[i];
letres=awaitinsertPost(db,data);
console.log(res);
// if the post doesn't have a parent thread, it is a thread. we need to insert the child posts too
// since
if(data.thread==null){
letreplies=[];
for(consteofposts_json){
if(e['thread']==data['postId']){
// since posts are already indexed by postID, which contains a timestamp to the nearest second, there's no risk for a post trying to add a backlink before the target exists
if(i==posts_json.length){console.log('Object ID not found in posts');process.exit(2);}
constdata=posts_json[i];
letres=awaitinsertPost(db,data);
console.log(res);
// if the post doesn't have a parent thread, it is a thread. we need to insert the child posts too
if(data.thread==null){
for(consteofposts_json){
if(e['thread']==data['postId']){
// since posts are already indexed by postID, which contains a timestamp to the nearest second, there's no risk for a post trying to add a backlink before the target exists
res=awaitinsertPost(db,e);
console.log(res);
}
}
}
}
console.log("Make sure to run `gulp html` and restore the attached files");
process.exit();
console.log('Make sure to run `gulp html` and restore the attached files');
process.exit();
})();
@ -75,7 +72,6 @@ async function insertPost(db, data) {
constpostMongoId=awaitdb.insertOne(data).then(result=>result.insertedId);//_id of post
constpostId=data['postId'];
constboard=data['board'];
//add backlinks to the posts this post quotes
if(data.thread&&data.quotes.length>0){
@ -110,15 +106,15 @@ async function insertPost(db, data) {