You are not logged in.
Pages: 1
Sorry I did not make it clear.
I mean accessing an array element by index, as per the example in the Mongo documentation https://docs.mongodb.com/manual/tutorial/query-arrays/.
For example, if I have a document, which has a field of type array, called "arrayField" and I want to access the second element, then in Mongo I could write the name followed by a dot and then index.
This is the syntax I assumed I could do:
"arrayField.1"
I assumed I would be able to access the document as a Variant by typing
var ParentDocument: Variant;
DocumentINeed: Variant;
...
begin
DocumentINeed := _Safe(ParentDocument).GetValueByPath('arrayField.1');
end;
I hope this makes it clear.
Hey!
I've recently tried to use "GetValueByPath" and "GetPVariantByPath" to access an element in a nested array using something similar to
_Safe(MongoDocument).GetValueByPath("arrayField.4");
where the element itself is a document.
This kind of path reference seems to be fully supported in Mongo 3
I seem to get a fake Variant and when looking at the source the function seems to exit if the Variant is not a DocVariant of some kind.
Am I correct in assuming this syntax is not supported?
Is there an appropriate way to access array elements in such a style?
Thank you very much in advance!
Pages: 1