# SQLite Fluent Interface A [fluent interface](https://en.wikipedia.org/wiki/Fluent_interface) implementation for writing SQLite queries within TypeScript and generating useful types based on the created queries. ## Examples ### Creating a user table ```ts const users_table = createTable("users") .ifNotExists() .withPrimaryKeyColumn("id", "INTEGER") .withRequiredColumn("name", "TEXT") .withRequiredColumn("username", "TEXT") .withOptionalColumn("age", "INTEGER"); // Generates the structure of the table as it passes through the fluent interface. actors_table.table.primaryKey.id; actors_table.table.alternateKeys.name; actors_table.table.alternateKeys.username; actors_table.table.alternateKeys.age; ``` ### Generating a SQLite table from the user table ```ts console.debug(users_table.build()); ``` ```sql CREATE TABLE users IF NOT EXISTS ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, username TEXT NOT NULL, age INTEGER ); ``` ### Inferring types from SQLite table ```ts type User = InferFromTable; // Shows up as type User = { id: number; name: string; username: string; age: number | null; } ````