Remove multiple documents from mongo in a single query

后端 未结 5 878
栀梦
栀梦 2020-11-30 02:16

I have a list of mongo \'_id\' which I want to delete. Currently I am doing this

# inactive_users -->  list of inactive users 
for item in inactive_users:         


        
5条回答
  •  感情败类
    2020-11-30 03:06

    List them all and use $in operator:

    db.users.remove({_id:{$in:[id1, id2, id3, ... ]}})
    

提交回复
热议问题