John Kouraklis 94 Posted September 29, 2019 Hi, does anyone have experience with MongoDB? Can it be used as a standalone file? Without the need for the end user to install a separate server with an app? Like an sqlite stand-alone db? Thx Share this post Link to post
stijnsanders 35 Posted September 29, 2019 (edited) Just to get to know MongoDB and what it's about, I once started the hard way and created a really bare-bones just-the-essentials connector to MongoDB: http://github.com/stijnsanders/TMongoWire So, no, I'm afraid the plain MongoDB isn't quite fit for embedding. A basic install would require a basic mongoDB installation alongside with your software. What you could do depending on what you would need from the data-component, is store your own list of JSON documents indexed by their "id" value... But that won't allow you to do clever queries like mongo has with the "$" prefixed query fields... Edited September 29, 2019 by stijnsanders Share this post Link to post
Arnaud Bouchez 407 Posted September 30, 2019 (edited) MongoDB benefit is to be installed in its server(s), with proper replication. Using it stand-alone is pointless. Use SQlite3 as embedded database. It supports JSON https://www.sqlite.org/json1.html efficiently. In practice, on some production project we used: - SQLite3 for almost everything (up to 1TB databases) - and we usually create several databases, e.g. per-user DB - MongoDB for storing huge content (more than 1TB databases) with replication: typically used as an archive service of "cold" data, which can be queried efficiently if you defined the proper indexes To let all this work from Delphi, we use our OpenSource http://mormot.net ORM, which is able to run efficiently on both storages, with the exact same code. The WHERE SQL query clauses are even translated on the fly to MongoDB pipelines by the ORM. One main trick is to put raw data as JSON in the RawJSON or TDocVariant ORM fields, then duplicate the fields to be queried as stand-alone ORM properties, with a proper index. Then you can query it very efficiently. Edited September 30, 2019 by Arnaud Bouchez Share this post Link to post
John Kouraklis 94 Posted October 1, 2019 I think I will go with the classic sqlite3 approach eventually. MongoDB needs proper setup and this complexity is not justified for the app I am looking at. Thanks a lot for the input Share this post Link to post