#1 Re: mORMot 2 » more than one results in AggregateDoc() - MongoDB » 2024-03-01 08:43:12

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?

#2 mORMot 2 » more than one results in AggregateDoc() - MongoDB » 2024-02-22 13:12:14

rove
Replies: 3

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

Board footer

Powered by FluxBB