MongoDB Database Guide
Finch uses mongo_dart package for MongoDB database operations. You can use the mongo_dart package to perform database operations in your Finch application.
Connect to MongoDB Database
To connect to MongoDB database, you need to add the following code to your app.dart file.
In the above example, we have enabled the MongoDB database and specified the host, port, username, password, and database name. You can change these values to match your database configuration.
Use MongoDB Database
To use the MongoDB database, you can use the app.mongoDb property. This property returns the Db object that you can use to perform database operations.
Database Collections
Finch provides a simple way to create database collections for MongoDB database. You can use the DBCollection class to define the structure of your database collection. The DBCollection class provides a simple way to define the fields of your collection. You can use the DBField classes to define the fields of your collection.
In the above example, we have defined a collection named example with two fields: title and slug. The title field is defined as a string and is set as the primary key. The slug field is defined as a string.
You can use the DBCollection class to create collections for your application. You can also use the DBCollection class to create relationships between collections. For example, you can define a foreign key relationship between two collections.
Querying Data
Finch provides a simple way to query data from your MongoDB database. You can use the modernFind method to query data from your collection. The modernFind method provides a simple way to query data from your collection. You can use the DQ class to build your query.
Example
For more information, you can check the example project in the Finch repository. The example project uses MongoDB database and Finch's database features.