RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
CodeDelphiRAD Studio

Learn How To Work With MongoDB Dataset In A Delphi application Quickly Using ListView Sample App

MongoDB is a document database, which means it stores data in JSON-like documents, the most natural way to think about data, and is much more expressive and powerful than the traditional row/column model. How about connecting with MongoDB using FireDAC components in your Application and access the dataset to show in a list view? Don’t know where to start? This post will guide you to do that.

MongoDB.ListView Sample App shows how to work with a sample MongoDB Database and show the data in the Listview.

You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.

Components used in MangoDB.ListView App:

  • TFDPhysMongoDriverLink: To link the MongoDB driver to an application and set it up. In general, it is enough to only include the FireDAC.Phys.MongoDB unit into your application uses a clause. The TFDPhysMongoDriverLink component can be used to specify: The VendorHome – the MongoDB installation root folder. The VendorLib – the name and the optional path to the MongoDB client library.
  • TFDConnection: To establish a connection to a DBMS and to manage associated datasets.
  • TListView: FireMonkey component that you can use to hold and present various types of items.

Implementation Details:

Before implementing this, as a preliminary step, we need to have a MongoDB Server is running and accessible from your host. For Details, See Connect to MongoDB Database. The “restaurants” collection of the “test” database is provisioned with test data. To provision this collection, run the MongoDB Restaurants Demo, and click the Load Data button: You can find the MongoDB Restaurants Demo sample project at: Object PascalDatabaseFireDACSamplesDBMS SpecificMongoDBRestaurants

  • This sample application illustrates how to connect to a MongoDB server, select specific documents from a sample collection “restaurants” using a select query, parse the selected document elements (JSON items), and then display the results using the TListView component.
  • Create a select query to retrieve specific documents from the sample MongoDB collection “restaurants” using the TMongoCollection.Find method.
  • Parse elements of the selected documents in one of the following ways:
  • using the TJSONIterator.Find method.
  • using the TJSONIterator.NextTJSONIterator.Recurse, and TJSONIterator.Return methods.
  • using the TJSONIterator.Iterate method.
  • Display the retrieved data using the TListView component.

Check out the full article in the DocWiki about the MongoDB.ListView Sample.

MongoDB ListView Sample App

Check out the full source code for the MongoDB.ListView projects for Delphi and C++Builder over on GitHub.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Learn More About Upgrading

Related posts
DelphiShowcase

Powerful Petroleum And Mining Software For Surface And Subsurface Data Visualization Is Built In Delphi

C++CodeDelphiIDE

Quickly Log Python Script Output To The Delphi Debug Log In Your Windows Apps

CodeDelphiRAD Studio

Learn How To Use Connection Pooling With A Multi-threaded Environment In Delphi

CodeDelphi

Learn How To Build A REST API App For iOS In 45 Minutes With Delphi

1 Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES