From 5fdd41efdae2ff4bb5b103bf052676645c75228d Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Tue, 13 Apr 2021 13:29:53 +0200 Subject: [PATCH] delete all owned studies --- bin/mongodb/user-gdpr-scrub.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/bin/mongodb/user-gdpr-scrub.js b/bin/mongodb/user-gdpr-scrub.js index abdfeb72d2..d6fae8b756 100644 --- a/bin/mongodb/user-gdpr-scrub.js +++ b/bin/mongodb/user-gdpr-scrub.js @@ -183,23 +183,18 @@ deleteAll('storm_day', '_id', new RegExp(`^${userId}:`)); deleteAll('streamer', '_id'); -replaceWithNewGhostIds('study', 'ownerId', studyDb); const studyIds = scrub( 'study', studyDb )(c => { + const ids = c.distinct('_id', { ownerId: userId }); + c.remove({ ownerId: userId }); c.updateMany({ likers: userId }, { $pull: { likers: userId } }); - const ids = c.distinct('_id', { uids: userId }); c.updateMany({ uids: userId }, { $pull: { uids: userId }, $unset: { [`members.${userId}`]: true } }); return ids; }); -scrub( - 'study_chapter_flat', - studyDb -)(c => - c.find({ _id: { $in: studyIds }, ownerId: userId }, { _id: 1 }).forEach(doc => setNewGhostId(c, doc, 'ownerId')) -); +scrub('study_chapter_flat', studyDb)(c => c.remove({ studyId: { $in: studyIds } })); deleteAllIn(studyDb, 'study_user_topic', '_id');