scripts.3.0.0.5-remove-orphan-documentation-pages.js Maven / Gradle / Ivy
print('find all orphan pages and remove them from db')
db.pages.find({parentId: {$exists: true}}).forEach(doc => {
const parentCursor = db.pages.find({_id: doc.parentId});
if (!parentCursor.hasNext()) {
//printjson(doc);
db.pages.remove(doc);
}
});