Skip to content

add object to array #42

@DDAGitHub

Description

@DDAGitHub

Hello.
Help, please, I can't to find the solution.

There is the object
{
"_id" : "id1",
"data" : [
{
"jobs" : [
{
"title" : "t1",
"type" : "tt1",
"category" : "c1"
},
{
"title" : "t2",
"type" : "tt2",
"category" : "c2"
}
]
}
]
}
I want to add the third job to the jobs array.
doc:=FMongoWire.Get(mwCollectionPersons,dSelector);
d0:= JSON(doc['data'][0]);
jobs_ru:= d0['jobs'];
n:= VarArrayHighBound(jobs_ru,1)+1;
VarArrayRedim(jobs_ru, n+1);
jobs_ru[n]:=JSON(['title','t3','type','tt3']);

fMongoWire.Update(mwCollectionPersons,dSelector,doc);
I have found that this code does not increase length of jobs array:

Could you posible to help me?
With best regards,
Dmitry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions