MongoDB - several Questions

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ernschd666
Posts: 11
Joined: Wed 15 Jul 2015 11:54

MongoDB - several Questions

Post by ernschd666 » Wed 11 Sep 2019 11:57

Hello,

I've read the instructions from here https://www.devart.com/unidac/docs/using-mongodb.htm, but I can't quite get along with using the components yet.

Can I create a collection? UniQuery1.SQL.Text := '{"create": "food"}'; doesn't work.
Or are there only the listed methods "find, insert, update, delete" availible?

Inserting new data works (I also checked with the MongoDB shell), but how can I read existing data?

I have tried the following:

Code: Select all

UniQuery1.SQL.Text := '{"insert":"restaurants", "documents":[{"_id":3, "name":"Venezia", "cuisine":"italian"}]}';
UniQuery1.Execute;
    
UniQuery1.SQL.Clear;
UniQuery1.Close;
UniQuery1.SQL.Text := '{"find":"restaurants", "filter":{"cuisine":"italian"}}';
// UniQuery1.SQL.Text := '{"find":"restaurants"}'; - alternatively, with no difference
UniQuery1.Open;    
RecordCount is then 0 - is that right?

Then I would like to print the contents of the document (but in my case document is NIL):

Code: Select all

var
  Document: TMongoDocument;
begin
Document := UniQuery1.GetObject('restaurants') as TMongoDocument;
ShowMessage(Document.Text);
Many thanks in advance.

Best regards,
Sven

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: MongoDB - several Questions

Post by ViktorV » Thu 12 Sep 2019 10:59

Currently the CREATE statements are not supported. You can request this functionality on our User Voice forum: https://devart.uservoice.com/forums/104 ... components to speed up the implementation of the functionality.
Unfortunately, we couldn't reproduce the issue with the latest UniDAC version 8.0.1 in our environment using the data that you've provided.
Please make sure that you use version 8.0.2 and try reproducing the issue.

Post Reply