How to get Multiple Documents in MongoDB? (Solved)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
rmcrodrigo1
Posts: 2
Joined: Tue 15 May 2018 17:04

How to get Multiple Documents in MongoDB? (Solved)

Post by rmcrodrigo1 » Tue 15 May 2018 17:18

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.
Last edited by rmcrodrigo1 on Wed 16 May 2018 17:24, edited 1 time in total.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: How to get Multiple Documents in MongoDB?

Post by azyk » Wed 16 May 2018 10:06

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;

rmcrodrigo1
Posts: 2
Joined: Tue 15 May 2018 17:04

Re: How to get Multiple Documents in MongoDB?

Post by rmcrodrigo1 » Wed 16 May 2018 17:24

thank you so much!

Post Reply