Database

Typetron provides an easy way to interact with a database using the Query Builder or the ORM. At this moment Typetron supports only SQLite as its driver(for prototyping purposes), but it will have support for major SQL and NoSQL databases as well.

In order to get started, you will have to create a database.sqlite file in your project’s directory(if it’s not created already) that will be used by the sqlite driver. Then update the config/database.ts config file with the name of the database file you’ve just created:

import { DatabaseConfig } from '@Typetron/Framework'

export default new DatabaseConfig({
    database: 'database.sqlite',
    entities: './Entities',
    synchronizeSchema: true,
})

This will open a SQLite connection between the app and the database.sqlite file.

By default, Typetron has the synchronizeSchema feature activate. This feature will synchronize all of your entities with your database. This feature should be used only in the development environment for rapid prototyping and should be deactivated (synchronizeSchema: false) in production environments.

Check the Query Builder to know how to get started to interact with a database.