0

I have a big MongoDB collection named ebola. I need to extract a subset of its first 1000 documents and save them into a new collection called sample. The code should be something like this:

db.createCollection("sample")  
db.sample.insert(db.ebola.find({}).limit(1000))  

But what is wrong with it?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Maryam
  • 1
  • 1
  • my bad! I edited the topic – Maryam Dec 10 '15 at 19:34
  • Oh sorry. in fact I am new with MongoDB and I want to get a subset from my collection which is too big and save that subset into a new collection in dat mongoDB database. – Maryam Dec 11 '15 at 01:57
  • Possible duplicate of [Save a subset of MongoDB(3.0) collection to another collection in Python](https://stackoverflow.com/questions/39959206/save-a-subset-of-mongodb3-0-collection-to-another-collection-in-python) (I realise this question was asked first, but the other almost identical question has an answer) – Jonny Sep 23 '19 at 11:15

0 Answers0