Skip to content

Instantly share code, notes, and snippets.

@enginkartal
Created December 27, 2015 17:01
Show Gist options
  • Save enginkartal/ed981878996fdd8344c9 to your computer and use it in GitHub Desktop.
Save enginkartal/ed981878996fdd8344c9 to your computer and use it in GitHub Desktop.
MongoDB Remove
//Author: Engin Kartal
//Blog Post: http://enginkartal.com.tr/mongodb-remove/
db.collection.remove(
<query>,
{
justOne: <boolean>,
writeConcern: <document>
}
)
//Tüm dokümanları sil
db.content.remove({});
//Bir koşula uyan dokümanları sil
//Aşağıdaki sorgu likes sayısı 7 olan tüm dokümanları siler.
db.content.remove({likes:7})
//Bir koşula uyan dokümanlardan tek kaydı sil
//Aşağıdaki sorgu likes sayısı 7 olan dokümanlardan sadece 1 tanesini siler.
db.content.remove({likes:7},1)
//ya da
db.content.remove({likes:7},true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment