Page 1 of 1

How to get Multiple Documents in MongoDB? (Solved)

Posted: Tue 15 May 2018 17:18
by rmcrodrigo1
I need to know how to get multiple documents, in your documetation, you are only giving an example about how to get a single document and how to save in the class TMongoDocument, but when the query should return multiple documents, the method TUniQuery.GetObject only returns a single document.

Re: How to get Multiple Documents in MongoDB?

Posted: Wed 16 May 2018 10:06
by azyk
You can use a loop to retrieve all the documents of the TUniQuery dataset. For example:

Code: Select all

  UniQuery1.Open;
  while not UniQuery1.Eof do begin
    Document := UniQuery1.GetObject('restaurants') as TMongoDocument;
    ...
    UniQuery1.Next;
  end;

Re: How to get Multiple Documents in MongoDB?

Posted: Wed 16 May 2018 17:24
by rmcrodrigo1
thank you so much!