You are not logged in.
Hi!
I have some problems when using mORMot with function TMongoCollection.AggregateDoc.
When using $limit:1 in operators, one result is returned as variant. But how to obtain results in case
when using $limit:5?
For example:
var
doc: variant;
begin
doc:= Coll.AggregateDoc('{$sort:{_id:-1}},{$limit:1}', []); ===> single record in doc is returned, OK!
but
doc:= Coll.AggregateDoc('{$sort:{_id:-1}},{$limit:5}', []); ===> multiple records as dvArray of TDocVariant should be returned(5 values)?
In multiple case, I did not able to read records from doc variable.
I am using Lazarus3.0
Offline
What is within doc? e.g. using string(doc) ?
Did you try to use _SafeArray(doc)^ to access the content?
I have added TMongoCollection.AggregateDocDict/AggregateDocList methods
since using IDocList may be easier for your usecase:
https://github.com/synopse/mORMot2/commit/d823a54f
Offline
Thank for you answer!
I migrated from mormot1 to mormot2 and the following code
doc: variant;
doc:=Coll.AggregateDoc('{ $sort : { _id: -1 } }, { $limit : 1 }',
[]);
does not return the result in mormot2, doc is empty.
But in mormot1, the function return one record.
What is the difference between mormot1 and mormot2?
Offline