Finch uses sqlite3 package for SQLite database operations. You can use the sqlite3 package to perform database operations in your Finch application.
Connect to SQLite Database
To connect to SQLite database, you need to add the following code to your app.dart file.
In the above example, we have enabled the SQLite database and specified the file path for the database file. You can change the file path to your desired location.
Use SQLite Database
To use the SQLite database, you can use the app.sqliteDb property. This property returns the Database object that you can use to perform database operations.
Database Models (Sql based tables)
Finch provides a simple way to create database models for SQLite database. You can use the MTable class to define the structure of your database table. The MTable class provides a simple way to define the fields of your table. You can use the MField classes to define the fields of your table.
In the above example, we have defined a table named users with three fields: id, name, and email. The id field is defined as an integer and is set as the primary key and auto-incremented. The name and email fields are defined as varchar with a maximum length of 255 characters.
You can use the MTable class to create tables for your application. You can also use the MTable class to create relationships between tables. For example, you can define a foreign key relationship between two tables.
Sqler
Finch uses sqler package to build SQL queries. You can use the sqler package to build SQL queries for your SQLite database. You can use the sqler package to build complex queries with ease.