0

I have e.g. this record:

{
    Id : "abc...",
    Name : "John Smith",
    List : [
        { Status : "failure abc" },
        { Status : "Success" },
        /*
            ... many many more like that ...
        */
        { Status : "Last entry" }
    ]
}

The List field is very very very long. Can I retrieve only the Id and Name fields, avoiding unnecessarily fetching whole List to save time?

Or do I have to just keep the List in its own collection or as independent record entry?

(Preferably C# code)

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Tar
  • 8,529
  • 9
  • 56
  • 127
  • You might want to reconsider having large embedded arrays in documents as they can lead to performance issues. For more information see [Why shouldn't I embed large arrays in my documents?](http://askasya.com/post/largeembeddedarrays). – Stennie Sep 23 '15 at 06:33

1 Answers1

2

Yes you can get only Id and name using mongodb's project fields like:

db.collection.find({},{"Id":1,"Name":1})
Vishwas
  • 6,967
  • 5
  • 42
  • 69