Closed DDAGitHub closed 8 years ago
use this:
d:=BSON([
'_id', 111,
'data',VarArrayOf([BSON(['f1',11]),BSON(['f2',22])])
]);
Thank you very much!
Another question. Sorry, I'am novice in the Mongo+BSON. I have an object: { "_id" : "001", "data" : [ {"f1": "1"}, {"f2": "2" } ] } dSelector:=BSON(['_id', "001"]); d:=FMongoWire.Get(mwCollection,dSelector); How now I can get access to the data array? And how I can update such objects?
With best regards, Dmitry
d['data']
will result in a variant array, you either use d['data'][0]
if you know/assume the length, or use VarArrayHighBound
and VarArrayLowBound
to iterate. You can make modifications to the local object d and use it with FMongoWire.Update
Hello. I can't understand how to create array of Objects in the created object. This code does not work — create simple array. d:=BSON([ '_id', 111, 'data',VarArrayOf(['[','f1',11,']','[','f2',22,']']), ]);
With best regards, Dmitry.