0
votes

I want to query subdocument which is "fields" object but the record return no results.

My code:

gares.find({"fields": ["id","fields.name"]};

"gares" Model

{"recordid": "1",
"fields": {
    "name":"verneuil",
    "country":"FR"
 },
"id": "585ab055578ee31431df8bf4"}

Response:

[{ "id": "585ab055578ee31431df8bf4"},]

I expect an output as:

[{ "id": "585ab055578ee31431df8bf4"}, "fields":{"name":"verneuil"}]

Someone help me please!

1
What's your expected output? - kevinadi
@KevinAdistambha I expect an output as: [{ "id": "585ab055578ee31431df8bf4"}, "fields":{"name":"verneuil"}] - AVIVA

1 Answers

0
votes

Incorrect syntax, Correct syntax as per doc is :

gares.find({"fields": {"id" : true,"fields.name" : true}};