Results 1 to 2 of 2

Thread: mongodb: how to remove all data from collection?

  1. #1
    Join Date
    Jan 2012
    Posts
    3

    Default mongodb: how to remove all data from collection?

    I need to remove all the data from certain collection.

    anybody knows how to perform this line using mongoTemplate:

    Code:
    >db.myCollection.remove({});
    i know there's a remove method but it needs a query, and i dont know how to create an empty query that selects all the documents in the collection.

    is it ok to call:
    Code:
    mongoTemplate.dropCollection("myCollection");

  2. #2
    Join Date
    Dec 2008
    Location
    Aurora, CO, USA
    Posts
    24

    Default

    Code:
    mongoTemplate.remove(new Query(), "collectionName");
    is the simplest way.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •