You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
622 B
25 lines
622 B
'use strict';
|
|
/* global db:true */
|
|
|
|
const comments = db.comments.find();
|
|
while (comments.hasNext()) {
|
|
const comment = comments.next();
|
|
print(`${comment.resourceType}:${comment._id}:${comment.resource}`);
|
|
|
|
let resource;
|
|
switch (comment.resourceType) {
|
|
case 'Post':
|
|
resource = db.posts.findOne({ _id: comment.resource });
|
|
break;
|
|
case 'Page':
|
|
resource = db.pages.findOne({ _id: comment.resource });
|
|
break;
|
|
}
|
|
if (resource) {
|
|
continue;
|
|
}
|
|
print('comment resource is missing!');
|
|
|
|
const result = db.comments.deleteMany({ resource: comment.resource });
|
|
printjson(result);
|
|
} |