These are chat archives for Automattic/mongoose

2nd
Mar 2019
Thierry
@devbieres
Mar 02 16:55
Hi !
Thierry
@devbieres
Mar 02 17:27
I've a document with a collection inside as a property. Is there a way when retreiving some documents to limit the number of the inside element ?
As an example :
{
"_id": ObjectId("5a53e4ed5352d103d4f33ae7"),
"name": "Test",
"list": [ { "name":"item 1" }, { "name":"item 2" }, { "name":"item 3" }, { "name":"item 4" } ... ]
},
{
"_id": ObjectId("5a53e4ed5352d103d4f33ae8"),
"name": "Test 2",
"list": [ { "name":"item 1" }, { "name":"item 2" }, { "name":"item 3" }, { "name":"item 4" } ... ]
}
I would to retrieve both doc but only the two first item of the list.
Thanks !
Thierry
@devbieres
Mar 02 21:04
The only I found is to loop on field after exec ...