sql_query_manager 1.0.1 copy "sql_query_manager: ^1.0.1" to clipboard
sql_query_manager: ^1.0.1 copied to clipboard

Sql Query generator for Dart.

pub package

Dart package for data management in SQL databases, primarily intended for use with the sqflite package.

Features #

Make Consults with Data-Classes #

Make Inserts with automatic validations #

Getting started #

Creates classes that extend TableSql, in which you must specify the Table Instance, Create Form, and Edit Form.

class MyTable
    extends TableSql<MyTable, MyTableCreationForm, MyTableEditionReplace> {
  ///The name of the table
  @override
  String get tableName => "name_of_my_table";

  ///Columns properties of the table
  ColumnSql get localId => ColumnSql(
      columnName: "local_id",
      addedInVersion: 1,
      dataType: SqlDataType.integer,
      primaryKey: true,
      autoIncrement: true);

  ColumnSql get otherColumn => ColumnSql(
      columnName: "other_column",
      addedInVersion: 1,
      dataType: SqlDataType.text,
      notNull: true,
      unique: true);

  ///This list is used for internal management of columns in the database
  @override
  List<ColumnSql> get columns => [localId, otherColumn];

  ///These will be the data that will be sent in the INSERT INTO
  @override
  Map<ColumnSql, dynamic> insertMap(final MyTableCreationForm creationForm) {
    return {otherColumn: creationForm.dataOfOtherColumn};
  }

  ///These will be the data that will be sent in the UPDATE
  @override
  Map<ColumnSql, dynamic> editMap(final MyTableEditionReplace editionForm) {
    return {otherColumn: editionForm.dataOfOtherColumn};
  }

  ///The instance must always reference itself (for internal use in development)
  @override
  get instance => this;
}

Usage #

Once you have the tables designed, you can start using them for the following purposes

Creation #

await MyTable().makeInsert(
database: database,
creationForm: MyTableCreationForm(dataOfOtherColumn: "Data"));

Visualization #

await database.rawQuery(MyTable().makeSelect());
1
likes
140
points
6
downloads

Publisher

unverified uploader

Weekly Downloads

Sql Query generator for Dart.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

intl, sqflite, sqflite_common

More

Packages that depend on sql_query_manager