Using truncate() on model removes all the documents and indexes where as it should only delete the documents.
Here's what i used
ModelName::truncate();
Actually there is no truncate method for MongoDB. There are two options, drop() or remove({}). First drops all documents and indexes but it is fast, the second one removes all documents in collection in a loop, it is slow, it doesn't free up the spaces used for documents and indexes.
Eloquent method truncate() is referring to drop() method on official mongodb/mongodb package.
If you want to just remove documents, i think something like ModelName::delete(); will work.
Ref: https://stackoverflow.com/questions/16493902/truncate-a-collection
@ysb yes but the library has a method truncate which should logically truncate the data than dropping the collection. Also here's the commit that fixed it, but I don't know why they reverted the change.
I believe that Collection::truncate() should use remove({}) for greater clarity and compatibility with Laravel. The speed of execution in this case is not so important.