Page 1 of 1

MongoDB - several Questions

Posted: Wed 11 Sep 2019 11:57
by ernschd666
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

Re: MongoDB - several Questions

Posted: Thu 12 Sep 2019 10:59
by ViktorV
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.