sqfEntity ORM for Flutter SQLite (sqflite)

Overview

sqfEntity ORM for Flutter SQLite (sqflite)

Sqf Entity ORM Preview

SqfEntity is based on SQFlite plugin and lets you build and execute SQL commands easily and quickly with the help of fluent methods similar to .Net Entity Framework

SqfEntity also generates add/edit forms with validations and special controls (DropDown List, DateTime pickers, Checkboxes.. etc) for your table.

Leave the job to SqfEntitiy for CRUD operations. Do easily and faster adding tables, adding columns, defining multiple tables, soft deleting, recovery, syncronize data from the web and more with the help of SqfEntityTable class.

If you have a bundled database, you can use it or EntityBase will create a new database automatically for you.

Open downloaded folder named sqfentity-master in VSCode and Click "Get Packages" button in the alert window that "Some packages are missing or out of date, would you like to get them now?"

Before Start: You can help us build the future sooner

If this project help you reduce time to develop, don't forget to click on the star on the top right of the page. Also you can give me a cup of coffee to help my sleepless nights :) https://www.patreon.com/hhtokpinar

What's New?

Added formTables parameter into dbModel to generate add/edit/list view controllers and added these special controls:

  • Validators (Required Fields, regular expression for data types)
  • DropdownList controls for related tables
  • Checkbox for boolean fields
  • DateTime picker for datetime field
  • Date picker for date field

See the application for sample use

Sqf Entity Generated Forms Preview

Getting Started

This project is a starting point for a SqfEntity ORM for database application. Some files in the project:

1. main.dart                      : Startup file contains sample methods for using sqfEntity
2. model / controller.dart        : main controller that provides access to created form views from
                                    the application main page (CAN BE MODIFIED)
3. model / model.dart             : Declare and modify your database model (CAN BE MODIFIED)
4. model / model.g.dart           : Sample generated model for examples (DO NOT MODIFY BY HAND)
5. model / model.g.view.dart      : Sample generated form views for examples (DO NOT MODIFY BY HAND)
6. model / view.list.dart         : The View that List your saved table items (CAN BE MODIFIED)
7. model / view.detail.dart       : The View that see detail selected item (CAN BE MODIFIED)
8. sample_advanced_form / *.dart  : Sample Widget showing how to filter toList() at runtime
9. assets / chinook.sqlite        : Sample db if you want to use an exiting database or create 
                                    model from database
10. app.dart                      : Sample App for display created model. 
11. LICENSE.txt                   : see this file for License Terms

dependencies:

Note: You do not need flutter_datetime_picker if you do not want to use the Form Generator property

dependencies:
  flutter_datetime_picker: ^1.2.8  
  sqfentity: ^1.2.3
  sqfentity_gen: ^1.2.3


dev_dependencies:
  build_runner: ^1.6.5
  build_verify: ^1.1.0

REQUIRED (sqlcipher for Android)

Flutter now enables code shrinking by default when building an APK in release mode, so you need to add the following ProGuard rules to the file android/app/proguard-rules.pro. If it does not exist, create it:

   -keep class net.sqlcipher.** { *; }

click to see: https://github.com/davidmartos96/sqflite_sqlcipher/blob/master/sqflite/README.md#android

Create a new Database Model

First, You need to:

  1. Copy these two files into your /lib/model folder: view.list.dart and view.detail.dart

  2. And copy this file helper.dart into your /lib/tools folder

  3. Create your model.dart file in lib/model/ folder to define your model and import sqfentity and other necessary packages

    import 'dart:convert';
    import 'dart:typed_data';
    import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
    import 'package:http/http.dart' as http;
    import 'package:flutter/material.dart';
    import 'package:sqfentity/sqfentity.dart';
    import 'package:sqfentity_gen/sqfentity_gen.dart';
    import '../tools/helper.dart';
    import 'view.list.dart';
    
  4. Write the following statement for the file to be created

    part 'model.g.dart';
    part 'model.g.view.dart'; // you do not need this part if you do not want to use the Form Generator property
    

Our model file is ready to use. Define your tables as shown in the example below.

STEP 1: For example, we have created 3 tables constant for category, product and todo that instanced from "SqfEntityTable" as follows:

Table 1: Category

// Define the 'tableCategory' constant as SqfEntityTable for the category table.
const tableCategory = SqfEntityTable(
  tableName: 'category',
  primaryKeyName: 'id',
  primaryKeyType: PrimaryKeyType.integer_auto_incremental,
  useSoftDeleting: true,
  modelName: null,
  fields: [
    SqfEntityField('name', DbType.text),
    SqfEntityField('isActive', DbType.bool, defaultValue: true),
  ]
);

If useSoftDeleting is true then, The builder engine creates a field named "isDeleted" on the table. When item was deleted then this field value is changed to "1" (does not hard delete) in this case it is possible to recover a deleted item using the recover() method. If the modelName (class name) is null then EntityBase uses TableName instead of modelName

Table 2: Product

// Define the 'tableProduct' constant as SqfEntityTable for the product table.
const tableProduct = SqfEntityTable(
  tableName: 'product',
  primaryKeyName: 'id',
  primaryKeyType: PrimaryKeyType.integer_auto_incremental,
  useSoftDeleting: true,
  fields: [
    SqfEntityField('name', DbType.text),
    SqfEntityField('description', DbType.text),
    SqfEntityField('price', DbType.real, defaultValue: 0),
    SqfEntityField('isActive', DbType.bool, defaultValue: true),
    SqfEntityFieldRelationship(
        parentTable: tableCategory,
        relationType: RelationType.ONE_TO_MANY,
        deleteRule: DeleteRule.CASCADE,
        defaultValue: 0), // Relationship column for CategoryId of Product
    SqfEntityField('rownum', DbType.integer,
        sequencedBy:
            seqIdentity /*Example of linking a column to a sequence */),
    SqfEntityField('imageUrl', DbType.text)
]);

If this table (Product) is the child of a parent table (Category), you must declare the SqfEntityFieldRelationship column into fields for Object Relational Mapping. You can choose one of the following for DeleteRule: CASCADE, NO ACTION, SET NULL, SET DEFAULT VALUE For more information about the rules Click here

Table 3: Todo

This table is for creating a synchronization with json data from the web url

const tableTodo = SqfEntityTable(
  tableName: 'todos',
  primaryKeyName: 'id',
  useSoftDeleting: false,
  primaryKeyType: PrimaryKeyType.integer_unique,
  defaultJsonUrl:
      'https://jsonplaceholder.typicode.com/todos', // optional: to synchronize your table with json data from webUrl

  // declare fields
  fields: [
    SqfEntityField('userId', DbType.integer),
    SqfEntityField('title', DbType.text),
    SqfEntityField('completed', DbType.bool, defaultValue: false)
]);

And add a Sequence for samples

const seqIdentity = SqfEntitySequence(
  sequenceName: 'identity',
  // maxValue:  10000, /* optional. default is max int (9.223.372.036.854.775.807) */
  // modelName: 'SQEidentity', 
                      /* optional. SqfEntity will set it to sequenceName automatically when the modelName is null*/
  // cycle : false,   /* optional. default is false; */
  // minValue = 0;    /* optional. default is 0 */
  // incrementBy = 1; /* optional. default is 1 */
  // startWith = 0;   /* optional. default is 0 */
);

And add a View for samples

    const tableV_tracks = SqfEntityTable(
        tableName: 'VTracks',
        objectType: ObjectType.view,
        fields: [
        SqfEntityField('Name', DbType.text),
        SqfEntityField('album', DbType.text),
        SqfEntityField('media', DbType.text),
        SqfEntityField('genres', DbType.text),
        SqfEntityFieldRelationship(
            parentTable: tableTrack,
            deleteRule: DeleteRule.NO_ACTION,
            fieldName: 'TrackId',
            isPrimaryKeyField: false),
        ],
        sqlStatement: '''SELECT
        trackid,
        track.name,
        album.Title AS album,
        mediatype.Name AS media,
        genre.Name AS genres
    FROM
        track
    INNER JOIN album ON Album.AlbumId = track.AlbumId
    INNER JOIN mediatype ON mediatype.MediaTypeId = track.MediaTypeId
    INNER JOIN genre ON genre.GenreId = track.GenreId''',
    );

2. Add your table objects you defined above to your dbModel

STEP 2: Create your Database Model to be instanced from SqfEntityModel Note: SqfEntity provides support for the use of multiple databases. So you can create many Database Models and use them in your application.

@SqfEntityBuilder(myDbModel)
const myDbModel = SqfEntityModel(
    modelName: 'MyDbModel', // optional
    databaseName: 'sampleORM.db',
    password: null, // You can set a password if you want to use crypted database 
                    (For more information: https://github.com/sqlcipher/sqlcipher)

    // put defined tables into the tables list.
    databaseTables: [tableCategory, tableProduct, tableTodo],
     // You can define tables to generate add/edit view forms if you want to use Form Generator property
    formTables: [tableProduct, tableCategory, tableTodo],
    // put defined sequences into the sequences list.
    sequences: [seqIdentity],
    bundledDatabasePath:
        null // 'assets/sample.db' // This value is optional. When bundledDatabasePath is empty then EntityBase creats a new database when initializing the database
);

That's all.. one more step left for create models.dart file. Go Terminal Window and run command below

flutter pub run build_runner build --delete-conflicting-outputs

After running the command Please check lib/model/model.g.dart and lib/model/model.g.view.dart (If formTables parameter is defined in the model)

Attach existing SQLite database with bundledDatabasePath parameter

bundledDatabasePath is optional. When bundledDatabasePath is empty then EntityBase creats a new database when initializing the database

How to import existing database and generate model automatically?

STEP 1

Copy your existing database in /assets folder (in this sample we have copied chinook.sqlite database) and define your asset database in pubspec.yaml as below

flutter:
  assets:
    - assets/chinook.sqlite

STEP 2

Run this script with this parameters.

databaseName: Specify a name for your database to use for the database connection

bundledDatabasePath: File path of your copied database

class BundledDbModel extends SqfEntityModelProvider {}

final bundledDbModel = await convertDatabaseToModelBase(BundledDbModel()
..databaseName = 'chinook.db'
..bundledDatabasePath = 'assets/chinook.sqlite');

STEP 3

Run this function to convert the model to annotation

final String modelConstString =
    SqfEntityConverter(bundledDbModel).createConstDatabase();

That's all. Set clipboard to paste codes

  await Clipboard.setData(ClipboardData(text: modelConstString));

Model were created succesfuly and set to the Clipboard.

Open model.dart file in lib/model folder and paste models after following line

part 'model.g.dart';

Go Terminal Window and run command below

flutter pub run build_runner build --delete-conflicting-outputs

Your Entity models will be created in lib/model/model.g.dart

Note: You can see this sample import in the createModelFromDatabaseSample() function in main.dart

Also you can generate your model from the main menu in Application as shown below when you make changes to your model while your project is running. Sqf Entity Generate Model.dart

Database initializer async method

When the application was initialize, initializeDB() method is performed automatically initilizeDb method runs that CREATE TABLE / ALTER TABLE ADD COLUMN queries for you.

void main(List args) async {
    runSamples();
    // If the database is not initialized, something went wrong. Check DEBUG CONSOLE for alerts
  }
}

That's Great! now we can use our created new models

Let's add some record to the "Category" table

Note: save() method returns the primary id of the added record

final notebookCategoryId = await Category(name: "Notebooks", isActive: true).save();

// or another way to define a category is Category.withField
final ultrabookCategoryId = await Category.withFields("Ultrabooks", true, false).save();

Let's add some record to the "Product" table

You can add record as follow:

final product = Product();
product.name = "Notebook 12\"";
product.description = "128 GB SSD i7";
product.price = 6899;
product.categoryId = notebookCategoryId;
await product.save();

You can also add records quickly as follows:

await Product.withFields( "Notebook 12\"", "128 GB SSD i7", 6899, true, notebookCategoryId, 0, false).save();
await Product.withFields( "Notebook 12\"", "256 GB SSD i7", 8244, true, notebookCategoryId, 0, false).save();
await Product.withFields( "Notebook 12\"", "512 GB SSD i7", 9214, true, notebookCategoryId, 0, false).save();
await Product.withFields( "Notebook 13\"", "128 GB SSD", 8500, true, notebookCategoryId, 0, false).save();
await Product.withFields( "Notebook 13\"", "256 GB SSD", 9900, true, notebookCategoryId, 0, false).save();
await Product.withFields( "Notebook 13\"", "512 GB SSD", 11000, null, notebookCategoryId, 0, false).save();
await Product.withFields( "Notebook 15\"", "128 GB SSD", 8999, null, notebookCategoryId, 0, false).save();
await Product.withFields( "Notebook 15\"", "256 GB SSD", 10499, null, notebookCategoryId, 0, false).save();
await Product.withFields( "Notebook 15\"", "512 GB SSD", 11999, true, notebookCategoryId, 0, false).save();

await Product.withFields( "Ultrabook 13\"", "128 GB SSD i5", 9954, true, ultrabookCategoryId, 0, false).save();
await Product.withFields( "Ultrabook 13\"", "256 GB SSD i5", 11154, true, ultrabookCategoryId, 0, false).save();
await Product.withFields( "Ultrabook 13\"", "512 GB SSD i5", 13000, true, ultrabookCategoryId, 0, false).save();
await Product.withFields( "Ultrabook 15\"", "128 GB SSD i7", 11000, true, ultrabookCategoryId, 0, false).save();
await Product.withFields( "Ultrabook 15\"", "256 GB SSD i7", 12000, true, ultrabookCategoryId, 0, false).save();
await Product.withFields( "Ultrabook 15\"", "512 GB SSD i7", 14000, true, ultrabookCategoryId, 0, false).save();

See sample usage of sqf below

To run this statement "SELECT * FROM PRODUCTS" Try below:

final productList = await Product().select().toList();

for (int i = 0; i < productList.length; i++) {
    print(productList[i].toMap());
}

To run this statement "SELECT * FROM PRODUCTS WHERE id=5" There are two way for this statement

The First is:

   var product = await Product().getById(5);

Second one is:

 var product = await Product().select().id.equals(5).toSingle();

SELECT FIELDS, ORDER BY EXAMPLES

await Product().select(columnsToSelect: ["name","price"]).orderByDesc("price").toList()">
EXAMPLE 1.2: ORDER BY FIELDS ex: SELECT * FROM PRODUCTS ORDER BY name, price DESC, id 
        -> await Product().select().orderBy("name").orderByDesc("price").orderBy("id").toList()

EXAMPLE 1.3: SELECT SPECIFIC FIELDS ex: SELECT name,price FROM PRODUCTS ORDER BY price DESC 
        -> await Product().select(columnsToSelect: ["name","price"]).orderByDesc("price").toList()

SELECT AND FILTER EXAMPLES:

await Product().select(columnsToSelect:["name","price"]) .price.lessThanOrEquals(10000) .and.startBlock.description.contains("128").or.description.endsWith("GB").endBlock .toList(); EXAMPLE 2.5: NOT EQUALS ex: SELECT * FROM PRODUCTS WHERE ID <> 11 -> await Product().select().id.not.equals(11).toList(); EXAMPLE 2.6: GREATERTHEN OR EQUALS, LESSTHAN OR EQUALS ex: SELECT * FROM PRODUCTS WHERE price>=10000 AND price<=13000 -> await Product().select().price.greaterThanOrEquals(10000).and.price.lessThanOrEquals(13000).toList(); EXAMPLE 2.7: BETWEEN ex: SELECT * FROM PRODUCTS WHERE price BETWEEN 8000 AND 14000 -> await Product().select().price.between(8000,14000).orderBy("price").toList(); EXAMPLE 2.8: 'NOT' KEYWORD ex: SELECT * FROM PRODUCTS WHERE NOT id>5 -> await Product().select().id.not.greaterThan(5).toList();">
EXAMPLE 2.1: EQUALS ex: SELECT * FROM PRODUCTS WHERE isActive=1 
->  await Product().select().isActive.equals(true).toList()

EXAMPLE 2.2: WHERE field IN (VALUES) ex: SELECT * FROM PRODUCTS WHERE ID IN (3,6,9) 
-> await Product().select().id.inValues([3,6,9]).toList()

EXAMPLE 2.3: BRACKETS ex: SELECT TOP 1 * FROM PRODUCTS WHERE price>10000 AND (description LIKE '%256%' OR description LIKE '512%') 
-> await  Product().select()
  .price
  .greaterThan(10000)
  .and.startBlock.description.contains("256").or.description.startsWith("512").endBlock
  .toSingle();

EXAMPLE 2.4: BRACKETS 2: SELECT name,price FROM PRODUCTS WHERE price<=10000 AND (description LIKE '%128%' OR description LIKE '%GB') 
->  await Product().select(columnsToSelect:["name","price"])
   .price.lessThanOrEquals(10000)
   .and.startBlock.description.contains("128").or.description.endsWith("GB").endBlock
   .toList();

EXAMPLE 2.5: NOT EQUALS ex: SELECT * FROM PRODUCTS WHERE ID <> 11 
-> await Product().select().id.not.equals(11).toList();
        
EXAMPLE 2.6: GREATERTHEN OR EQUALS, LESSTHAN OR EQUALS ex: SELECT * FROM PRODUCTS WHERE price>=10000 AND price<=13000 
-> await Product().select().price.greaterThanOrEquals(10000).and.price.lessThanOrEquals(13000).toList();        

EXAMPLE 2.7: BETWEEN ex: SELECT * FROM PRODUCTS WHERE price BETWEEN 8000 AND 14000 
-> await Product().select().price.between(8000,14000).orderBy("price").toList();

EXAMPLE 2.8: 'NOT' KEYWORD ex: SELECT * FROM PRODUCTS WHERE NOT id>5 
-> await Product().select().id.not.greaterThan(5).toList();

WRITE CUSTOM SQL FILTER

8000").toList() EXAMPLE 2.10: Build filter and query from values from the form -> await Product().select() .price.between(minPrice, maxPrice) .and.name.contains(nameFilter) .and.description.contains(descFilter) .toList()">
EXAMPLE 2.9: WRITING CUSTOM FILTER IN WHERE CLAUSE ex: SELECT * FROM PRODUCTS WHERE id IN (3,6,9) OR price>8000 
-> await Product().select().where("id IN (3,6,9) OR price>8000").toList()

EXAMPLE 2.10: Build filter and query from values from the form
-> await Product().select()
   .price.between(minPrice, maxPrice)
   .and.name.contains(nameFilter)
   .and.description.contains(descFilter)
   .toList()

SELECT WITH DELETED ITEMS (SOFT DELETE WHEN USED)

EXAMPLE 2.11: EXAMPLE 1.13: Select products with deleted items
-> await Product().select(getIsDeleted: true).toList()

EXAMPLE 2.12: Select products only deleted items 
-> await Product().select(getIsDeleted: true).isDeleted.equals(true).toList()

LIMITATION, PAGING

await Product().select().page(3,5).toList()">
EXAMPLE 3.1: LIMITATION SELECT TOP 3 * FROM PRODUCTS ORDER BY price DESC 
-> await Product().select().orderByDesc("price").top(3).toList()

EXAMPLE 3.2: PAGING: PRODUCTS in 3. page (5 items per page) 
-> await Product().select().page(3,5).toList()

DISTINCT

EXAMPLE 4.1: DISTINCT: SELECT DISTINCT name FROM PRODUCTS WHERE price > 3000 
-> await Product().distinct(columnsToSelect:["name"]).price.greaterThan(3000).toList();

GROUP BY

EXAMPLE 4.2: GROUP BY WITH SCALAR OR AGGREGATE FUNCTIONS
SELECT name, COUNT(id) AS Count, MIN(price) AS minPrice, MAX(price) AS maxPrice, AVG(price) AS
avgPrice, SUM(price) AS sumPrice FROM PRODUCTS GROUP BY name 
-> await Product()
    .select(columnsToSelect: [
    ProductFields.name.toString(),
    ProductFields.id.count("Count"),
    ProductFields.price.min("minPrice"),
    ProductFields.price.max("maxPrice"),
    ProductFields.price.avg("avgPrice"),
    ProductFields.price.sum("sumPrice"),
  ])
  .groupBy(ProductFields.name.toString() /*also you can use this .groupBy("name")*/)
  .toListObject();

RELATIONSHIPS

EXAMPLE 7.1: goto Category from Product 

final product = await Product().getById(1);
final category = await product.getCategory();
print(category.toMap());

Results:
{id: 1, name: Notebooks, isActive: true, isDeleted: false}


EXAMPLE 7.2: Products of 'Notebooks Category' listing 

final category = await Category().getById(1);
final productList = await category.getProducts();

for(var product in productList) {
   print(product.toMap());
   }

Results: Products of 'Notebooks' listing 9 matches found:
{id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 1, isDeleted: false}
{id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
....

These were just a few samples. You can download and review dozens of examples written below

save() Method for insert or update (for both)

await Product(name:"test product").save(); // inserts a new record if id is null or equals to zero
await Product(id:1, name:"test product").save(); // updates record

saveAll() Method for insert or update List (for both)

result of saveAll method is following:"); for (var result in results) { print(result.toString()); }">
var productList= List();
// TO DO.. add products to list

// Save All products in the List
 final results = await Product().saveAll(productList);
 
print(" List result of saveAll method is following:");
for (var result in results) {
   print(result.toString());
}

upsertAll() Method for insert or update List (for both)

Note: upsertAll() method is faster then saveAll() method. upsertAll() should be used when you are sure that the primary key is greater than zero

var productList= List();
// TO DO.. add products to list with ID (ID>0) (primary key must be greater then 0)

// Upsert All products in the List
final results = await Product().upsertAll(productList);
for (var result in results) {
    print(result.toString());  
}

UPDATE multiple records with query

EXAMPLE 5.1: UPDATE PRODUCT SET isActive=0 WHERE ID>=10

final result = await Product().select().id.greaterThan(10).update({"isActive": 0});
print(result.toString());

DELETE multiple records with query

EXAMPLE 6.4: DELETE PRODUCT WHERE ID>17

final result = await Product().select().id.greaterThan(17).delete();
print(result.toString());

Syncronize data from the web

EXAMPLE 8.2: Fill List from web with Url (JSON data) and saveAll

Step 1: Todo.fromWebUrl("URL",(todosList){}) method gets json data from the web and loads into the todosList

Step 2: Call Todo().upsertAll(todosList) method saves all data in your local database

 todosList = await Todo.fromWebUrl("https://jsonplaceholder.typicode.com/todos");
  final results = await Todo().upsertAll(todosList);

  // print upsert Results
  for (var res in results) {
    print(res.toString()); 
  }

  todosList = await Todo().select().top(10).toList();
  print(todosList.length.toString() + " matches found\n");
  for (var todo in todosList) {
    print(todo.toMap());
  }

Run sql raw query on database, or get datatable

EXAMPLE 9.1: Execute custom SQL command on database

final sql = "UPDATE product set isActive=1 where isActive=1";
final result = await MyDbModel().execSQL(sql);
print(result.toString());

result:

flutter: sql command executed successfully

EXAMPLE 9.2: Execute custom SQL command List on database

final sqlList=List();
final result = await MyDbModel().execSQLList(sqlList);
print(result.toString());

result:

sql command list executed successfuly

EXAMPLE 9.3 Execute custom SQL Query and get datatable -> returns List>

await MyDbModel().execDataTable('SELECT name, price FROM product order by price desc LIMIT 5');

result: (5 row)

    flutter: {name: Ultrabook 15", price: 14000.0}
    flutter: {name: Ultrabook 13", price: 13000.0}
    flutter: {name: Ultrabook 15", price: 12000.0}
    flutter: {name: Notebook 15", price: 11999.0}
    flutter: {name: Ultrabook 13", price: 11154.0}

EXAMPLE 9.4 Execute custom SQL Query and get first col of first row (execute scalar)

await MyDbModel().execScalar('SELECT name FROM product order by price desc');

result: (1 row)

 flutter: Ultrabook 15"

EXAMPLE 10 SqfEntity Sequence Samples

final int currentVal = await IdentitySequence().currentVal();
final int nextVal = await IdentitySequence().nextVal();
final int nextVal2 = await IdentitySequence().nextVal();
final int currentVal2 = await IdentitySequence().currentVal();

// You can reset sequence anytime
final int currentVal3 = await IdentitySequence().reset();

print("""
IdentitySequence().currentVal = $currentVal
IdentitySequence().nextVal = $nextVal
IdentitySequence().nextVal = $nextVal2
IdentitySequence().currentVal = $currentVal2
IdentitySequence().reset = $currentVal3 // returns start value
""");

CONVERTING ANY OBJECT OR LIST TO Json METHOD (WITH NESTED/RELATIONED OBJECTS)

EXAMPLE 11.1 single object to Json

final product = Product().select().toSingle();
final jsonString = product.toJson();
print(jsonString);

result is:

flutter: {"id":1,"name":"Notebook 12\"","description":"128 GB SSD i7","price":6899.0,"isActive":true,"categoryId":1,"rownum":1,"imageUrl":"https://raw..","isDeleted":false}

EXAMPLE 11.2 object list with nested objects to Json

final jsonStringWithChilds =  await Category().select().toJson(); // all categories selected
print(jsonStringWithChilds);

result is:

flutter: [{"id":1,"name":"Notebooks","isActive":true,"isDeleted":false,"products":[{"id":1,"name":"Notebook 12\"","description":"128 GB SSD i7","price":6899.0,"isActive":1,"categoryId":1,"rownum":1,"imageUrl":"https://raw.githubusercontent.com/hhtokpinar/sqfEntity/master/example/assets/notebook.png","isDeleted":0},{"id":2,"name":"Notebook 12\"","description":"256 GB SSD i7","price":8244.0,"isActive":1,"categoryId":1,"rownum":2,"imageUrl":"https://raw.githubusercontent.com/hhtokpinar/sqfEntity/master/example/assets/notebook.png","isDeleted":0},{"id":3,"name":"Notebook 12\"","description":"512 GB SSD i7","price":9214.0,"isActive":1,"categoryId":1,"rownum":3,"imageUrl":"https://raw.githubusercontent.com/hhtokpinar/sqfEntity/master/example/assets/notebook.png","isDeleted":0}....
.........................

}

GET SOME DATA FROM THE VIEW

  final vtracs = await VTrack().select().top(5).toList(); 

Result:

  flutter: 5 matches found
  flutter: {Name: For Those About To Rock (We Salute You), album: For Those About To Rock We Salute You, media: MPEG audio file, genres: Rock, TrackId: 1}
  flutter: {Name: Balls to the Wall, album: Balls to the Wall, media: Protected AAC audio file, genres: Rock, TrackId: 2}
  flutter: {Name: Fast As a Shark, album: Restless and Wild, media: Protected AAC audio file, genres: Rock, TrackId: 3}
  flutter: {Name: Restless and Wild, album: Restless and Wild, media: Protected AAC audio file, genres: Rock, TrackId: 4}
  flutter: {Name: Princess of the Dawn, album: Restless and Wild, media: Protected AAC audio file, genres: Rock, TrackId: 5}

See the following examples in main.dart for sample model use

  // SELECT AND ORDER PRODUCTS BY FIELDS
  samples1();

  // FILTERS: SOME FILTERS ON PRODUCTS
  samples2();

  // LIMITATIONS: PAGING, TOP X ROW
  samples3();

  // DISTINCT, GROUP BY with SQL AGGREGATE FUNCTIONS,
  samples4();

  // UPDATE BATCH, UPDATE OBJECT
  samples5();

  // DELETE BATCH, DELETE OBJECT
  samples6();

  // ORM (Object Relational Mapping) SAMPLE
  samples7();

  // Fill List from the web (JSON)
  samples8();

  // Run custom raw sql query on database
  samples9();

SAMPLE APPLICATION

main.dart includes many examples of what you need, as well as what we can see. Also This sample project includes a sample application on how you can use sqfentity

SqfEntity Sample Mobile Application for Flutter

in this sample application:

  • List Category (Home Screen)
  • Add, Delete, Recover Categories
  • Category Statistics (Count, minPrice, maxPrice, avgPrice, sumPrice.. etc)

after clicking the category

  • List Products, order by name or price
  • Search Form with SqfEntity search
  • Add, Delete, Recover Products
  • Product Detail Page

helper tools

  • Popup Window
  • SlideMenu
  • Global Setting
  • Generate Model.dart and set to Clipboard

You can also see samples for soft delete, CASCADE delete, recover and CASCADE recover in this application

Enjoy..

Running the main.dart should show the following result at DEBUG CONSOLE:

Product().select().orderBy("name").orderByDesc("price").orderBy("id").toList() flutter 20 matches found: flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter EXAMPLE 1.3: SELECT SPECIFIC FIELDS ex: SELECT name,price FROM PRODUCTS ORDER BY price DESC flutter -> Product().select(columnsToSelect: ["name","price"]).orderByDesc("price").toList() flutter flutter flutter 20 matches found: flutter {name: Ultrabook 15", price: 14000.0} flutter {name: Ultrabook 13", price: 13000.0} flutter {name: Ultrabook 15", price: 12000.0} flutter {name: Notebook 15", price: 11999.0} flutter {name: Ultrabook 13", price: 11154.0} flutter {name: Notebook 13", price: 11000.0} flutter {name: Ultrabook 15", price: 11000.0} flutter {name: Notebook 15", price: 10499.0} flutter {name: Ultrabook 13", price: 9954.0} flutter {name: Notebook 13", price: 9900.0} flutter {name: Notebook 12", price: 9214.0} flutter {name: Notebook 15", price: 8999.0} flutter {name: Notebook 13", price: 8500.0} flutter {name: Notebook 12", price: 8244.0} flutter {name: Notebook 12", price: 6899.0} flutter {name: Product 1, price: 0.0} flutter {name: Product 2, price: 0.0} flutter {name: Product 3, price: 0.0} flutter {name: Product 4, price: 0.0} flutter {name: Product 5, price: 0.0} flutter --------------------------------------------------------------- flutter flutter flutter EXAMPLE 1.4: EQUALS ex: SELECT * FROM PRODUCTS WHERE isActive=1 flutter -> Product().select().isActive.equals(true).toList() flutter 17 matches found: flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.5: WHERE field IN (VALUES) ex: SELECT * FROM PRODUCTS WHERE ID IN (3,6,9) flutter -> Product().select().id.inValues([3,6,9]).toList() flutter 3 matches found: flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.6: BRACKETS ex: SELECT TOP 1 * FROM PRODUCTS WHERE price>10000 AND (description LIKE '%256%' OR description LIKE '512%') flutter -> Product().select().price.greaterThan(10000).and.startBlock.description.contains("256").or.description.startsWith("512").endBlock.toSingle((product){ // TO DO }) flutter Toplam 1 sonuç listeleniyor: flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.7: BRACKETS 2 ex: SELECT name,price FROM PRODUCTS WHERE price <=10000 AND (description LIKE '%128%' OR description LIKE '%GB') flutter -> Product().select(columnsToSelect:["name","price"]).price.lessThanOrEquals(10000).and.startBlock.description.contains("128").or.description.endsWith("GB").endBlock.toList(); flutter 4 matches found: flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.8: NOT EQUALS ex: SELECT * FROM PRODUCTS WHERE ID <> 11 flutter -> Product().select().id.not.equals(11).toList(); flutter 19 matches found: flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.9: GREATERTHEN OR EQUALS, LESSTHAN OR EQUALS ex: SELECT * FROM PRODUCTS WHERE price>=10000 AND price<=13000 flutter -> Product().select().price.greaterThanOrEquals(10000).and.price.lessThanOrEquals(13000).toList(); flutter 7 matches found: flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.10: BETWEEN ex: SELECT * FROM PRODUCTS WHERE price BETWEEN 8000 AND 14000 flutter -> Product().select().price.between(8000,14000).orderBy("price").toList(); flutter 14 matches found: flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.11: 'NOT' KEYWORD ex: SELECT * FROM PRODUCTS WHERE NOT id>5 flutter -> Product().select().id.not.greaterThan(5).toList(); flutter 5 matches found: flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.12: WRITING CUSTOM FILTER IN WHERE CLAUSE ex: SELECT * FROM PRODUCTS WHERE id IN (3,6,9) OR price>8000 flutter -> Product().select().where("id IN (3,6,9) OR price>8000").toList() flutter 14 matches found: flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.13: Product().select().price.between(8000, 10000).and.name.contains("13").and.description.contains("SSD").toList() flutter 3 matches found: flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.14: EXAMPLE 1.13: Select products with deleted items flutter -> Product().select(getIsDeleted: true).toList() flutter 20 matches found: flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 1.15: Select products only deleted items flutter -> Product().select(getIsDeleted: true).isDeleted.equals(true).toList() flutter 0 matches found: flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 3.1: LIMITATION ex: SELECT TOP 3 * FROM PRODUCTS ORDER BY price DESC flutter -> Product().select().orderByDesc("price").top(3).toList() flutter 3 matches found: flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 3.2: SAMPLE PAGING ex: PRODUCTS in 3. page (5 items per page) flutter -> Product().select().page(3,5).toList() flutter 5 matches found: flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 4.1: DISTINCT ex: SELECT DISTINCT name FROM PRODUCTS WHERE price > 3000 flutter -> Product().distinct(columnsToSelect:["name").price.greaterThan(3000).toList(); flutter 5 matches found: flutter {name: Notebook 12"} flutter {name: Notebook 13"} flutter {name: Notebook 15"} flutter {name: Ultrabook 13"} flutter {name: Ultrabook 15"} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 4.2: GROUP BY WITH SCALAR OR AGGREGATE FUNCTIONS ex: SELECT name, COUNT(id) AS Count, MIN(price) AS minPrice, MAX(price) AS maxPrice, AVG(price) AS avgPrice,ProductFields.price.sum("sumPrice") FROM PRODUCTS GROUP BY name flutter -> Product().select(columnsToSelect: [ProductFields.name.toString(), ProductFields.id.count("Count"), ProductFields.price.min("minPrice"), ProductFields.price.max("maxPrice"), ProductFields.price.avg("avgPrice")).groupBy(ProductFields.name.toString()).toListObject() flutter 10 matches found: flutter {name: Notebook 12", Count: 3, minPrice: 6899.0, maxPrice: 9214.0, avgPrice: 8119.0, sumPrice: 24357.0} flutter {name: Notebook 13", Count: 3, minPrice: 8500.0, maxPrice: 11000.0, avgPrice: 9800.0, sumPrice: 29400.0} flutter {name: Notebook 15", Count: 3, minPrice: 8999.0, maxPrice: 11999.0, avgPrice: 10499.0, sumPrice: 31497.0} flutter {name: Product 1, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0} flutter {name: Product 2, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0} flutter {name: Product 3, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0} flutter {name: Product 4, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0} flutter {name: Product 5, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0} flutter {name: Ultrabook 13", Count: 3, minPrice: 9954.0, maxPrice: 13000.0, avgPrice: 11369.333333333334, sumPrice: 34108.0} flutter {name: Ultrabook 15", Count: 3, minPrice: 11000.0, maxPrice: 14000.0, avgPrice: 12333.333333333334, sumPrice: 37000.0} flutter --------------------------------------------------------------- flutter EXAMPLE 5.1: Update multiple records with query flutter -> Product().select().id.greaterThan(10).update({"isActive": 0}); flutter 10 items updated flutter --------------------------------------------------------------- flutter flutter EXAMPLE 5.2: uUpdate multiple records with query flutter -> Product().select().id.lessThanOrEquals(10).update({"isActive": 1}); flutter 10 items updated flutter --------------------------------------------------------------- flutter flutter EXAMPLE 5.3: id=15 Product item updated: {id: 15, name: Ultrabook 15", description: 512 GB SSD i7 (updated), price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter flutter EXAMPLE 5.4: update some filtered products with saveAll method flutter -> Product().saveAll(productList){}); flutter List result of saveAll method is following: flutter id=1 upserted successfuly flutter id=2 upserted successfuly flutter id=3 upserted successfuly flutter id=4 upserted successfuly flutter id=5 upserted successfuly flutter id=6 upserted successfuly flutter id=7 upserted successfuly flutter id=8 upserted successfuly flutter id=9 upserted successfuly flutter id=10 upserted successfuly flutter id=11 upserted successfuly flutter id=12 upserted successfuly flutter id=13 upserted successfuly flutter id=14 upserted successfuly flutter id=15 upserted successfuly flutter id=16 upserted successfuly flutter id=17 upserted successfuly flutter id=18 upserted successfuly flutter id=19 upserted successfuly flutter id=20 upserted successfuly flutter --------------------------------------------------------------- flutter EXAMPLE 5.4: listing saved products (set rownum=i) with saveAll method; flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 1, isDeleted: false} flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 2, isDeleted: false} flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 3, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 4, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 5, isDeleted: false} flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: true, categoryId: 1, rownum: 6, isDeleted: false} flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: true, categoryId: 1, rownum: 7, isDeleted: false} flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: true, categoryId: 1, rownum: 8, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 9, isDeleted: false} flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 10, isDeleted: false} flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: false, categoryId: 2, rownum: 11, isDeleted: false} flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: false, categoryId: 2, rownum: 12, isDeleted: false} flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: false, categoryId: 2, rownum: 13, isDeleted: false} flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: false, categoryId: 2, rownum: 14, isDeleted: false} flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7 (updated), price: 14000.0, isActive: true, categoryId: 2, rownum: 15, isDeleted: false} flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 16, isDeleted: false} flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 17, isDeleted: false} flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 18, isDeleted: false} flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 19, isDeleted: false} flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 20, isDeleted: false} flutter --------------------------------------------------------------- flutter EXAMPLE 6.2: delete product by query filder flutter -> Product().select().id.equals(16).delete(); flutter 1 items updated flutter --------------------------------------------------------------- flutter flutter SQFENTITIY: delete Product invoked (id=17) flutter EXAMPLE 6.3: delete product if exist flutter -> if (product != null) Product.delete(); flutter 1 items updated flutter --------------------------------------------------------------- flutter flutter EXAMPLE 6.4: Delete many products by filter flutter -> Product().select().id.greaterThan(17).delete() flutter 3 items updated flutter --------------------------------------------------------------- flutter flutter SQFENTITIY: recover Product batch invoked flutter EXAMPLE 6.6: Recover many products by filter flutter -> Product().select().id.greaterThan(17).recover() flutter 3 items updated flutter --------------------------------------------------------------- flutter flutter EXAMPLE 7.1: goto Category Object from Product flutter -> Product.getCategory(); flutter The category of 'Notebook 12"' is: {id: 1, name: Notebooks, isActive: true, isDeleted: false} flutter flutter flutter EXAMPLE 7.2.1: Products of 'Notebooks' listing flutter -> category.getProducts((productList) {}); flutter 9 matches found: flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 1, isDeleted: false} flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 2, isDeleted: false} flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 3, isDeleted: false} flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 4, isDeleted: false} flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 5, isDeleted: false} flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: true, categoryId: 1, rownum: 6, isDeleted: false} flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: true, categoryId: 1, rownum: 7, isDeleted: false} flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: true, categoryId: 1, rownum: 8, isDeleted: false} flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 9, isDeleted: false} flutter --------------------------------------------------------------- flutter flutter flutter EXAMPLE 8.1: Fill List from web (JSON data) and upsertAll flutter -> Todo.fromWeb((todosList) {} flutter 10 matches found flutter {id: 1, userId: 1, title: delectus aut autem, completed: false} flutter {id: 2, userId: 1, title: quis ut nam facilis et officia qui, completed: false} flutter {id: 3, userId: 1, title: fugiat veniam minus, completed: false} flutter {id: 4, userId: 1, title: et porro tempora, completed: false} flutter {id: 5, userId: 1, title: laboriosam mollitia et enim quasi adipisci quia provident illum, completed: false} flutter {id: 6, userId: 1, title: qui ullam ratione quibusdam voluptatem quia omnis, completed: false} flutter {id: 7, userId: 1, title: illo expedita consequatur quia in, completed: false} flutter {id: 8, userId: 1, title: quo adipisci enim quam ut ab, completed: false} flutter {id: 9, userId: 1, title: molestiae perspiciatis ipsa, completed: false} flutter {id: 10, userId: 1, title: illo est ratione doloremque quia maiores aut, completed: false} flutter --------------------------------------------------------------- flutter flutter EXAMPLE 8.2: upsertAll result flutter -> final results = await Todo().upsertAll(todosList); flutter flutter flutter EXAMPLE 8.2: Fill List from web with Url (JSON data) and upsertAll flutter -> Todo.fromWebUrl("https://jsonplaceholder.typicode.com/todos", (todosList) {} flutter 10 matches found flutter {id: 1, userId: 1, title: delectus aut autem, completed: false} flutter {id: 2, userId: 1, title: quis ut nam facilis et officia qui, completed: false} flutter {id: 3, userId: 1, title: fugiat veniam minus, completed: false} flutter {id: 4, userId: 1, title: et porro tempora, completed: false} flutter {id: 5, userId: 1, title: laboriosam mollitia et enim quasi adipisci quia provident illum, completed: false} flutter {id: 6, userId: 1, title: qui ullam ratione quibusdam voluptatem quia omnis, completed: false} flutter {id: 7, userId: 1, title: illo expedita consequatur quia in, completed: false} flutter {id: 8, userId: 1, title: quo adipisci enim quam ut ab, completed: false} flutter {id: 9, userId: 1, title: molestiae perspiciatis ipsa, completed: false} flutter {id: 10, userId: 1, title: illo est ratione doloremque quia maiores aut, completed: false} flutter --------------------------------------------------------------- flutter: EX.9.1 Execute custom SQL command on database flutter: -> final sql='UPDATE product set isActive=1 where isActive=1'; flutter: -> MyDbModel().execSQL(sql) flutter: -> print result = sql command executed successfully flutter: EX.9.2 Execute custom SQL command List on database flutter: -> final sqlList=List(); flutter: -> MyDbModel().execSQLList(sqlList); flutter: -> print result = sql command list executed successfuly flutter: EX.9.3 Execute custom SQL Query and get datatable -> returns List> flutter: -> MyDbModel().execDataTable('SELECT name, price FROM product order by price desc LIMIT 5'); flutter: -> print result: flutter: {name: Ultrabook 15", price: 14000.0} flutter: {name: Ultrabook 13", price: 13000.0} flutter: {name: Ultrabook 15", price: 12000.0} flutter: {name: Notebook 15", price: 11999.0} flutter: {name: Ultrabook 13", price: 11154.0} flutter: EX.9.4 Execute custom SQL Query and get first col of first row -> returns dynamic flutter: -> MyDbModel().execScalar('SELECT name FROM product order by price desc'); flutter: -> print result: flutter: Ultrabook 15" flutter: EXAMPLE 10 SqfEntity Sequence SAMPLES----------- flutter: Sample Code: flutter: final currentVal= await IdentitySequence().currentVal(); flutter: result: currentVal = 9 flutter: final nextVal = await IdentitySequence().nextVal(); flutter: result: nextVal = 10 flutter: final int nextVal2 = await IdentitySequence().nextVal(); flutter: result: nextVal2 = 0 flutter: final int currentVal2 = await IdentitySequence().currentVal(); flutter: result: currentVal2 = 0 flutter: final int currentVal3 = await IdentitySequence().reset(); flutter: result: currentVal3 = 0">
flutter >>>>>>>>>>>>>>>>>>>>>>>>>>>> SqfEntityTable of 'category' initialized successfuly
flutter >>>>>>>>>>>>>>>>>>>>>>>>>>>> SqfEntityTable of 'product' initialized successfuly
flutter >>>>>>>>>>>>>>>>>>>>>>>>>>>> SqfEntityTable of 'todos' initialized successfuly
D/EGL_emulation( 6184): eglMakeCurrent: 0xe6ed49a0: ver 3 0 (tinfo 0xcf020470)
flutter SQFENTITIY: [databaseTables] Model was created successfully. Create models.dart file in your project and press Ctrl+V to paste the model from the Clipboard
flutter sampleORMx01.db created successfully
flutter SQFENTITIY: Table named 'product' was initialized successfuly with create new table
flutter SQFENTITIY: alterTableIndexesQuery => [CREATE INDEX IF NOT EXISTS IDXCategorycategoryId ON product (categoryId ASC)]
flutter SQFENTITIY: Table named 'category' was initialized successfuly with create new table
flutter SQFENTITIY: Table named 'todos' was initialized successfuly with create new table
flutter SQFENTITIY: The database is ready for use
flutter
flutter
flutter added 15 new products
flutter added 5 dummy products
flutter
flutter
flutter LISTING CATEGORIES -> Category().select().toList()
flutter 2 matches found:
flutter {id: 1, name: Notebooks, isActive: true, isDeleted: false}
flutter {id: 2, name: Ultrabooks, isActive: true, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.1: SELECT ALL ROWS WITHOUT FILTER ex: SELECT * FROM PRODUCTS
flutter  -> Product().select().toList()
flutter 20 matches found:
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.2: ORDER BY FIELDS ex: SELECT * FROM PRODUCTS ORDER BY name, price DESC, id
flutter -> Product().select().orderBy("name").orderByDesc("price").orderBy("id").toList()
flutter 20 matches found:
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter EXAMPLE 1.3: SELECT SPECIFIC FIELDS ex: SELECT name,price FROM PRODUCTS ORDER BY price DESC
flutter -> Product().select(columnsToSelect: ["name","price"]).orderByDesc("price").toList()
flutter
flutter
flutter 20 matches found:
flutter {name: Ultrabook 15", price: 14000.0}
flutter {name: Ultrabook 13", price: 13000.0}
flutter {name: Ultrabook 15", price: 12000.0}
flutter {name: Notebook 15", price: 11999.0}
flutter {name: Ultrabook 13", price: 11154.0}
flutter {name: Notebook 13", price: 11000.0}
flutter {name: Ultrabook 15", price: 11000.0}
flutter {name: Notebook 15", price: 10499.0}
flutter {name: Ultrabook 13", price: 9954.0}
flutter {name: Notebook 13", price: 9900.0}
flutter {name: Notebook 12", price: 9214.0}
flutter {name: Notebook 15", price: 8999.0}
flutter {name: Notebook 13", price: 8500.0}
flutter {name: Notebook 12", price: 8244.0}
flutter {name: Notebook 12", price: 6899.0}
flutter {name: Product 1, price: 0.0}
flutter {name: Product 2, price: 0.0}
flutter {name: Product 3, price: 0.0}
flutter {name: Product 4, price: 0.0}
flutter {name: Product 5, price: 0.0}
flutter ---------------------------------------------------------------
flutter
flutter
flutter EXAMPLE 1.4: EQUALS ex: SELECT * FROM PRODUCTS WHERE isActive=1
flutter ->  Product().select().isActive.equals(true).toList()
flutter 17 matches found:
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.5: WHERE field IN (VALUES) ex: SELECT * FROM PRODUCTS WHERE ID IN (3,6,9)
flutter  -> Product().select().id.inValues([3,6,9]).toList()
flutter 3 matches found:
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.6: BRACKETS ex: SELECT TOP 1 * FROM PRODUCTS WHERE price>10000 AND (description LIKE '%256%' OR description LIKE '512%')
flutter  -> Product().select().price.greaterThan(10000).and.startBlock.description.contains("256").or.description.startsWith("512").endBlock.toSingle((product){ // TO DO })
flutter Toplam 1 sonuç listeleniyor:
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.7: BRACKETS 2 ex: SELECT name,price FROM PRODUCTS WHERE price <=10000 AND (description LIKE '%128%' OR description LIKE '%GB')
flutter  -> Product().select(columnsToSelect:["name","price"]).price.lessThanOrEquals(10000).and.startBlock.description.contains("128").or.description.endsWith("GB").endBlock.toList();
flutter 4 matches found:
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.8: NOT EQUALS ex: SELECT * FROM PRODUCTS WHERE ID <> 11
flutter  -> Product().select().id.not.equals(11).toList();
flutter 19 matches found:
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.9: GREATERTHEN OR EQUALS, LESSTHAN OR EQUALS ex: SELECT * FROM PRODUCTS WHERE price>=10000 AND price<=13000
flutter  -> Product().select().price.greaterThanOrEquals(10000).and.price.lessThanOrEquals(13000).toList();
flutter 7 matches found:
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.10: BETWEEN ex: SELECT * FROM PRODUCTS WHERE price BETWEEN 8000 AND 14000
flutter  -> Product().select().price.between(8000,14000).orderBy("price").toList();
flutter 14 matches found:
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.11: 'NOT' KEYWORD ex: SELECT * FROM PRODUCTS WHERE NOT id>5
flutter  -> Product().select().id.not.greaterThan(5).toList();
flutter 5 matches found:
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.12: WRITING CUSTOM FILTER IN WHERE CLAUSE ex: SELECT * FROM PRODUCTS WHERE id IN (3,6,9) OR price>8000
flutter  -> Product().select().where("id IN (3,6,9) OR price>8000").toList()
flutter 14 matches found:
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.13: Product().select().price.between(8000, 10000).and.name.contains("13").and.description.contains("SSD").toList()
flutter 3 matches found:
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.14: EXAMPLE 1.13: Select products with deleted items
flutter  -> Product().select(getIsDeleted: true).toList()
flutter 20 matches found:
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: false, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 0, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: true, categoryId: 0, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 1.15: Select products only deleted items
flutter  -> Product().select(getIsDeleted: true).isDeleted.equals(true).toList()
flutter 0 matches found:
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 3.1: LIMITATION ex: SELECT TOP 3 * FROM PRODUCTS ORDER BY price DESC
flutter  -> Product().select().orderByDesc("price").top(3).toList()
flutter 3 matches found:
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 3.2: SAMPLE PAGING ex: PRODUCTS in 3. page (5 items per page)
flutter  -> Product().select().page(3,5).toList()
flutter 5 matches found:
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7, price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 4.1: DISTINCT ex: SELECT DISTINCT name FROM PRODUCTS WHERE price > 3000
flutter  -> Product().distinct(columnsToSelect:["name").price.greaterThan(3000).toList();
flutter 5 matches found:
flutter {name: Notebook 12"}
flutter {name: Notebook 13"}
flutter {name: Notebook 15"}
flutter {name: Ultrabook 13"}
flutter {name: Ultrabook 15"}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 4.2: GROUP BY WITH SCALAR OR AGGREGATE FUNCTIONS ex: SELECT name, COUNT(id) AS Count, MIN(price) AS minPrice, MAX(price) AS maxPrice, AVG(price) AS avgPrice,ProductFields.price.sum("sumPrice") FROM PRODUCTS GROUP BY name
flutter -> Product().select(columnsToSelect: [ProductFields.name.toString(), ProductFields.id.count("Count"), ProductFields.price.min("minPrice"), ProductFields.price.max("maxPrice"), ProductFields.price.avg("avgPrice")).groupBy(ProductFields.name.toString()).toListObject()
flutter 10 matches found:
flutter {name: Notebook 12", Count: 3, minPrice: 6899.0, maxPrice: 9214.0, avgPrice: 8119.0, sumPrice: 24357.0}
flutter {name: Notebook 13", Count: 3, minPrice: 8500.0, maxPrice: 11000.0, avgPrice: 9800.0, sumPrice: 29400.0}
flutter {name: Notebook 15", Count: 3, minPrice: 8999.0, maxPrice: 11999.0, avgPrice: 10499.0, sumPrice: 31497.0}
flutter {name: Product 1, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0}
flutter {name: Product 2, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0}
flutter {name: Product 3, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0}
flutter {name: Product 4, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0}
flutter {name: Product 5, Count: 1, minPrice: 0.0, maxPrice: 0.0, avgPrice: 0.0, sumPrice: 0.0}
flutter {name: Ultrabook 13", Count: 3, minPrice: 9954.0, maxPrice: 13000.0, avgPrice: 11369.333333333334, sumPrice: 34108.0}
flutter {name: Ultrabook 15", Count: 3, minPrice: 11000.0, maxPrice: 14000.0, avgPrice: 12333.333333333334, sumPrice: 37000.0}
flutter ---------------------------------------------------------------
flutter EXAMPLE 5.1: Update multiple records with query
flutter  -> Product().select().id.greaterThan(10).update({"isActive": 0});
flutter 10 items updated
flutter ---------------------------------------------------------------
flutter
flutter EXAMPLE 5.2: uUpdate multiple records with query
flutter  -> Product().select().id.lessThanOrEquals(10).update({"isActive": 1});
flutter 10 items updated
flutter ---------------------------------------------------------------
flutter
flutter EXAMPLE 5.3: id=15 Product item updated: {id: 15, name: Ultrabook 15", description: 512 GB SSD i7 (updated), price: 14000.0, isActive: true, categoryId: 2, rownum: 0, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter
flutter EXAMPLE 5.4: update some filtered products with saveAll method
flutter  -> Product().saveAll(productList){});
flutter  List result of saveAll method is following:
flutter id=1 upserted successfuly
flutter id=2 upserted successfuly
flutter id=3 upserted successfuly
flutter id=4 upserted successfuly
flutter id=5 upserted successfuly
flutter id=6 upserted successfuly
flutter id=7 upserted successfuly
flutter id=8 upserted successfuly
flutter id=9 upserted successfuly
flutter id=10 upserted successfuly
flutter id=11 upserted successfuly
flutter id=12 upserted successfuly
flutter id=13 upserted successfuly
flutter id=14 upserted successfuly
flutter id=15 upserted successfuly
flutter id=16 upserted successfuly
flutter id=17 upserted successfuly
flutter id=18 upserted successfuly
flutter id=19 upserted successfuly
flutter id=20 upserted successfuly
flutter ---------------------------------------------------------------
flutter EXAMPLE 5.4: listing saved products (set rownum=i) with saveAll method;
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 1, isDeleted: false}
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 2, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 3, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 4, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 5, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: true, categoryId: 1, rownum: 6, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: true, categoryId: 1, rownum: 7, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: true, categoryId: 1, rownum: 8, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 9, isDeleted: false}
flutter {id: 10, name: Ultrabook 13", description: 128 GB SSD i5, price: 9954.0, isActive: true, categoryId: 2, rownum: 10, isDeleted: false}
flutter {id: 11, name: Ultrabook 13", description: 256 GB SSD i5, price: 11154.0, isActive: false, categoryId: 2, rownum: 11, isDeleted: false}
flutter {id: 12, name: Ultrabook 13", description: 512 GB SSD i5, price: 13000.0, isActive: false, categoryId: 2, rownum: 12, isDeleted: false}
flutter {id: 13, name: Ultrabook 15", description: 128 GB SSD i7, price: 11000.0, isActive: false, categoryId: 2, rownum: 13, isDeleted: false}
flutter {id: 14, name: Ultrabook 15", description: 256 GB SSD i7, price: 12000.0, isActive: false, categoryId: 2, rownum: 14, isDeleted: false}
flutter {id: 15, name: Ultrabook 15", description: 512 GB SSD i7 (updated), price: 14000.0, isActive: true, categoryId: 2, rownum: 15, isDeleted: false}
flutter {id: 16, name: Product 1, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 16, isDeleted: false}
flutter {id: 17, name: Product 2, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 17, isDeleted: false}
flutter {id: 18, name: Product 3, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 18, isDeleted: false}
flutter {id: 19, name: Product 4, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 19, isDeleted: false}
flutter {id: 20, name: Product 5, description: , price: 0.0, isActive: false, categoryId: 0, rownum: 20, isDeleted: false}
flutter ---------------------------------------------------------------
flutter EXAMPLE 6.2: delete product by query filder
flutter  -> Product().select().id.equals(16).delete();
flutter 1 items updated
flutter ---------------------------------------------------------------
flutter
flutter SQFENTITIY: delete Product invoked (id=17)
flutter EXAMPLE 6.3: delete product if exist
flutter  -> if (product != null) Product.delete();
flutter 1 items updated
flutter ---------------------------------------------------------------
flutter
flutter EXAMPLE 6.4: Delete many products by filter
flutter  -> Product().select().id.greaterThan(17).delete()
flutter 3 items updated
flutter ---------------------------------------------------------------
flutter
flutter SQFENTITIY: recover Product batch invoked
flutter EXAMPLE 6.6: Recover many products by filter
flutter  -> Product().select().id.greaterThan(17).recover()
flutter 3 items updated
flutter ---------------------------------------------------------------
flutter
flutter EXAMPLE 7.1: goto Category Object from Product
flutter -> Product.getCategory();
flutter The category of 'Notebook 12"' is: {id: 1, name: Notebooks, isActive: true, isDeleted: false}
flutter
flutter
flutter EXAMPLE 7.2.1: Products of 'Notebooks' listing
flutter -> category.getProducts((productList) {});
flutter 9 matches found:
flutter {id: 1, name: Notebook 12", description: 128 GB SSD i7, price: 6899.0, isActive: true, categoryId: 1, rownum: 1, isDeleted: false}
flutter {id: 2, name: Notebook 12", description: 256 GB SSD i7, price: 8244.0, isActive: true, categoryId: 1, rownum: 2, isDeleted: false}
flutter {id: 3, name: Notebook 12", description: 512 GB SSD i7, price: 9214.0, isActive: true, categoryId: 1, rownum: 3, isDeleted: false}
flutter {id: 4, name: Notebook 13", description: 128 GB SSD, price: 8500.0, isActive: true, categoryId: 1, rownum: 4, isDeleted: false}
flutter {id: 5, name: Notebook 13", description: 256 GB SSD, price: 9900.0, isActive: true, categoryId: 1, rownum: 5, isDeleted: false}
flutter {id: 6, name: Notebook 13", description: 512 GB SSD, price: 11000.0, isActive: true, categoryId: 1, rownum: 6, isDeleted: false}
flutter {id: 7, name: Notebook 15", description: 128 GB SSD, price: 8999.0, isActive: true, categoryId: 1, rownum: 7, isDeleted: false}
flutter {id: 8, name: Notebook 15", description: 256 GB SSD, price: 10499.0, isActive: true, categoryId: 1, rownum: 8, isDeleted: false}
flutter {id: 9, name: Notebook 15", description: 512 GB SSD, price: 11999.0, isActive: true, categoryId: 1, rownum: 9, isDeleted: false}
flutter ---------------------------------------------------------------
flutter
flutter
flutter EXAMPLE 8.1: Fill List from web (JSON data) and upsertAll
flutter  -> Todo.fromWeb((todosList) {}
flutter 10 matches found
flutter {id: 1, userId: 1, title: delectus aut autem, completed: false}
flutter {id: 2, userId: 1, title: quis ut nam facilis et officia qui, completed: false}
flutter {id: 3, userId: 1, title: fugiat veniam minus, completed: false}
flutter {id: 4, userId: 1, title: et porro tempora, completed: false}
flutter {id: 5, userId: 1, title: laboriosam mollitia et enim quasi adipisci quia provident illum, completed: false}
flutter {id: 6, userId: 1, title: qui ullam ratione quibusdam voluptatem quia omnis, completed: false}
flutter {id: 7, userId: 1, title: illo expedita consequatur quia in, completed: false}
flutter {id: 8, userId: 1, title: quo adipisci enim quam ut ab, completed: false}
flutter {id: 9, userId: 1, title: molestiae perspiciatis ipsa, completed: false}
flutter {id: 10, userId: 1, title: illo est ratione doloremque quia maiores aut, completed: false}
flutter ---------------------------------------------------------------
flutter
flutter EXAMPLE 8.2: upsertAll result
flutter  -> final results = await Todo().upsertAll(todosList);
flutter
flutter
flutter EXAMPLE 8.2: Fill List from web with Url (JSON data) and upsertAll
flutter  -> Todo.fromWebUrl("https://jsonplaceholder.typicode.com/todos", (todosList) {}
flutter 10 matches found
flutter {id: 1, userId: 1, title: delectus aut autem, completed: false}
flutter {id: 2, userId: 1, title: quis ut nam facilis et officia qui, completed: false}
flutter {id: 3, userId: 1, title: fugiat veniam minus, completed: false}
flutter {id: 4, userId: 1, title: et porro tempora, completed: false}
flutter {id: 5, userId: 1, title: laboriosam mollitia et enim quasi adipisci quia provident illum, completed: false}
flutter {id: 6, userId: 1, title: qui ullam ratione quibusdam voluptatem quia omnis, completed: false}
flutter {id: 7, userId: 1, title: illo expedita consequatur quia in, completed: false}
flutter {id: 8, userId: 1, title: quo adipisci enim quam ut ab, completed: false}
flutter {id: 9, userId: 1, title: molestiae perspiciatis ipsa, completed: false}
flutter {id: 10, userId: 1, title: illo est ratione doloremque quia maiores aut, completed: false}
flutter ---------------------------------------------------------------

flutter: EX.9.1 Execute custom SQL command on database
flutter:  -> final sql='UPDATE product set isActive=1 where isActive=1';
flutter:  -> MyDbModel().execSQL(sql)
flutter:  -> print result = sql command executed successfully

flutter: EX.9.2 Execute custom SQL command List on database
flutter:  -> final sqlList=List();
flutter:  -> MyDbModel().execSQLList(sqlList);
flutter:  -> print result = sql command list executed successfuly

flutter: EX.9.3 Execute custom SQL Query and get datatable -> returns List>
flutter:  -> MyDbModel().execDataTable('SELECT name, price FROM product order by price desc LIMIT 5');
flutter:  -> print result:
flutter: {name: Ultrabook 15", price: 14000.0}
flutter: {name: Ultrabook 13", price: 13000.0}
flutter: {name: Ultrabook 15", price: 12000.0}
flutter: {name: Notebook 15", price: 11999.0}
flutter: {name: Ultrabook 13", price: 11154.0}

flutter: EX.9.4 Execute custom SQL Query and get first col of first row -> returns dynamic
flutter:  -> MyDbModel().execScalar('SELECT name FROM product order by price desc');
flutter:  -> print result:
flutter: Ultrabook 15"

flutter: EXAMPLE 10 SqfEntity Sequence SAMPLES-----------
flutter: Sample Code:
flutter:   final currentVal= await IdentitySequence().currentVal();
flutter:   result: currentVal = 9
flutter:   final nextVal = await IdentitySequence().nextVal();
flutter:   result: nextVal = 10
flutter:   final int nextVal2 = await IdentitySequence().nextVal();
flutter:   result: nextVal2 = 0
flutter:   final int currentVal2 = await IdentitySequence().currentVal();
flutter:   result: currentVal2 = 0
flutter:   final int currentVal3 = await IdentitySequence().reset();
flutter:   result: currentVal3 = 0
Comments
  • Local DB Synchronization from webUrl lag! And New Problem in latest version.

    Local DB Synchronization from webUrl lag! And New Problem in latest version.

    Hey Bro, I Hope you are well.

    I am working now with version 1.3.1 for both packages and they are working well.

    When upgraded to latest version and rebuilt the models, a problem occured.

    I am using

    futureCatList = shop
            .get_category_tables()
            .toList(preload: true, preloadFields: ['plProducts_tables']);
    

    in latest version, the first category_tables Products only preloaded and the others Categories loaded with nor products.

    This is the problem of the new version..

    Thanks

    opened by a7mdragab 93
  • Unhandled Exception: DatabaseException(no such table: tablename(code 1 SQLITE_ERROR):

    Unhandled Exception: DatabaseException(no such table: tablename(code 1 SQLITE_ERROR):

    Hey bro, I am really appreciate your work, thanks for your effort. I have a problem since yesterday, the app was working fine. But after upgrading my flutter sdk to the lateset version:

    Flutter 1.15.4-pre.66 • channel master
    

    , an exception named no such table appeared as follows:

    I/flutter ( 5505): init() -> modelname: null, tableUser_table:user_wish_table
    I/flutter ( 5505): >>>>>>>>>>>>>>>>>>>>>>>>>>>> SqfEntityTableBase of [user_table](wish_id) init() successfuly
    
    E/SQLiteLog( 5505): (1) no such table: user_table
    
    E/flutter ( 5505): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: DatabaseException(no such table: user_wish_table (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM user_wish_table) sql 'SELECT * FROM user_table' args []}
    
    E/flutter ( 5505): <asynchronous suspension>
    E/flutter ( 5505): #11     User_tableFilterBuilder.toMapList (package:test/Models/model.g.dart:21011:42)
    E/flutter ( 5505): #12     User_tableFilterBuilder.toList (package:test/Models/model.g.dart:20979:24)
    

    I rebuilt the model.g file but no change. This happens for all tables. do you have any explanation? Thanks in advance

    opened by a7mdragab 57
  • Supporting MySql field type 'time' and add private class FieldType

    Supporting MySql field type 'time' and add private class FieldType

    Hello bro, I'd like to support the MySql field type 'time'. Here are the functions

    dbType: DbType.time           //Value: hh:mm:ss       ex: 23:30:10
    fieldType: TimeOfDay?
    
    in fromMap()
    fromString(s): time = TimeOfDay(hour: int.parse(s.split(":")[0]), minute: int.parse(s.split(":")[1]));
    
    in toMap()
    toString(): '${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}:00';
    
    

    Also, adding support for personal classes given that the class must contain fromMap, toMap functions. The import for that class should be done manually in model.dart

    dbType: DbType.privateClass, privateClassType: MyOwnClass
    fieldType: MyOwnClass?
    
    in fromMap()
    obj = MyOwnClass.fromMap(o['MyOwnClass']);
    
    in toMap()
    obj = MyOwnClass.toMap();
    
    opened by a7mdragab 47
  • Virtual fields and preloading

    Virtual fields and preloading

    I couldn't find any equivalent of .Net Entity Framework's virtual fields in this package, which is fields declared in the model that only generates fields in the model class and not in the database table. They are used to store lists of preloaded rows from other tables.

    In my example, I have a list of contests which all have an owner. Each contest has on owner id. When I'm loading the list of contests, I also want to load their owners, since i'll be displaying both the contest's and the owner's name the next time I'm updating the app's state. I then find myself either putting both the contest and the owners into a list of keyword maps, or creating two separate lists where I have to continously sort out the right owner I need for every contest displayed. It would be more convenient and effecient in my case, both for code readability and efficiency, to just have a owner field in my contest class where I could put the preloaded owner, and then just get the name by calling Contest.owner.name.

    A workaround is to use the custom code feature to add a field directly to the contest class which can hold the preloaded element, and it seems to work just fine. It would just feel and look better to be able to do something along the lines of SqfEntityField('owner', DbType.virtual, table: tableOwner) which could generate the field Owner owner in the contest class, but not create a row in the database table. It would also have been nice to be able to preload by just writing Contest().select().preload(['owner']), instead of having to do multiple queries, also inspired by the .Net Entity Framework.

    opened by tverra 40
  • Sqfentity not working with error NoSuchMethodError: The getter 'index' was called on null. Receiver: null Tried calling: index

    Sqfentity not working with error NoSuchMethodError: The getter 'index' was called on null. Receiver: null Tried calling: index

    on the example it does not runs and shows the following

    [INFO] Generating build script...
    [INFO] Generating build script completed, took 652ms
    
    [INFO] Creating build script snapshot......
    [INFO] Creating build script snapshot... completed, took 26.2s
    
    [INFO] Initializing inputs
    [INFO] Building new asset graph...
    [INFO] Building new asset graph completed, took 1.9s
    
    [INFO] Checking for unexpected pre-existing outputs....
    [INFO] Checking for unexpected pre-existing outputs. completed, took 12ms
    
    [INFO] Running build...
    [INFO] Generating SDK summary...
    [INFO] 11.1s elapsed, 0/5 actions completed.
    [INFO] Generating SDK summary completed, took 11.3s
    
    [INFO] 12.8s elapsed, 0/5 actions completed.
    [INFO] 14.5s elapsed, 0/5 actions completed.
    [WARNING] No actions completed for 15.1s, waiting on:
      - sqfentity_gen:property_sqfentity on lib/model/chinook.dart
      - sqfentity_gen:property_sqfentity on lib/model/view.list.dart
      - sqfentity_gen:property_sqfentity on lib/model/view.detail.dart
      - sqfentity_gen:property_sqfentity on lib/model/controller.dart
      - sqfentity_gen:property_sqfentity on lib/model/model.dart
    
    [INFO] 17.2s elapsed, 0/5 actions completed.
    [INFO] 18.2s elapsed, 0/5 actions completed.
    [INFO] 19.2s elapsed, 0/5 actions completed.
    [INFO] 20.5s elapsed, 0/5 actions completed.
    [INFO] 21.6s elapsed, 0/5 actions completed.
    [INFO] 22.6s elapsed, 0/5 actions completed.
    [INFO] 24.1s elapsed, 0/5 actions completed.
    [INFO] 25.5s elapsed, 0/5 actions completed.
    [INFO] 26.7s elapsed, 0/5 actions completed.
    [INFO] 28.2s elapsed, 0/5 actions completed.
    [INFO] 29.6s elapsed, 0/5 actions completed.
    [WARNING] No actions completed for 15.0s, waiting on:
      - sqfentity_gen:property_sqfentity on lib/model/chinook.dart
      - sqfentity_gen:property_sqfentity on lib/model/view.list.dart
      - sqfentity_gen:property_sqfentity on lib/model/view.detail.dart
      - sqfentity_gen:property_sqfentity on lib/model/controller.dart
      - sqfentity_gen:property_sqfentity on lib/model/model.dart
    
    [INFO] 31.3s elapsed, 0/5 actions completed.
    [INFO] 32.3s elapsed, 0/5 actions completed.
    [INFO] 33.3s elapsed, 0/5 actions completed.
    [INFO] 34.5s elapsed, 0/5 actions completed.
    [INFO] 36.4s elapsed, 0/5 actions completed.
    [INFO] 37.6s elapsed, 0/5 actions completed.
    [INFO] 39.4s elapsed, 0/5 actions completed.
    [INFO] 55.2s elapsed, 0/5 actions completed.
    [WARNING] No actions completed for 25.0s, waiting on:
      - sqfentity_gen:property_sqfentity on lib/model/chinook.dart
      - sqfentity_gen:property_sqfentity on lib/model/view.list.dart
      - sqfentity_gen:property_sqfentity on lib/model/view.detail.dart
      - sqfentity_gen:property_sqfentity on lib/model/controller.dart
      - sqfentity_gen:property_sqfentity on lib/model/model.dart
    
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    SQFENTITY GENERATOR STARTED... instance Of:* chinookdb
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    SQFENTITY GENERATOR: builder initialized (* chinookdb)...
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    SQFENTITY_GEN.DART: recognizing Tables (Chinookdb)
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: Album
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: Artist
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:Artist
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:Album
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: Customer
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: Employee
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    __________toSqfEntityTable() returned null
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:Employee
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:Customer
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: Genre
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:Genre
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: Invoice
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:Invoice
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: InvoiceLine
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: Track
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: MediaType
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:MediaType
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: Playlist
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:Playlist
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:Track
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:InvoiceLine
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    -------------------------------------------------------TABLE RECOGNIZING: VTracks
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    init() -> tableName:VTracks
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    SQFENTITY_GEN.DART: recognizing Tables (Chinookdb)
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    Chinookdb Model recognized succesfuly
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    11 tables found in Chinookdb
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    Chinookdb converted to SqfEntityModelBase successfully
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    createEntites() started
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    >>> OBJECTTYPE.TABLE Album(Title,ArtistId,) converting to entity
    [SEVERE] sqfentity_gen:property_sqfentity on lib/model/chinook.dart:
    
    NoSuchMethodError: The getter 'index' was called on null.
    Receiver: null
    Tried calling: index
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    SQFENTITY GENERATOR STARTED... instance Of:* myDbModel
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    SQFENTITY GENERATOR: builder initialized (* myDbModel)...
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    SQFENTITY_GEN.DART: recognizing Sequences (null)
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    SQFENTITY_GEN.DART: recognizing Tables (MyDbModel)
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    -------------------------------------------------------TABLE RECOGNIZING: product
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    -------------------------------------------------------TABLE RECOGNIZING: category
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    init() -> tableName:category
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    init() -> tableName:product
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    -------------------------------------------------------TABLE RECOGNIZING: todos
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    init() -> tableName:todos
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    SQFENTITY_GEN.DART: recognizing Tables (MyDbModel)
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    MyDbModel Model recognized succesfuly
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    3 tables found in MyDbModel
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    MyDbModel converted to SqfEntityModelBase successfully
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    createEntites() started
    [WARNING] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    >>> OBJECTTYPE.TABLE product(name,description,price,isActive,categoryId,rownum,imageUrl,datetime,date,) converting to entity
    [SEVERE] sqfentity_gen:property_sqfentity on lib/model/model.dart:
    
    NoSuchMethodError: The getter 'index' was called on null.
    Receiver: null
    Tried calling: index
    [INFO] 1m 14s elapsed, 19/33 actions completed.
    [INFO] 1m 15s elapsed, 21/33 actions completed.
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/model/chinook.dart:
    -------------------------------------------------------FormBuilder: SqfEntityTable
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/model/chinook.dart:
    SQFENTITY_GEN.DART: recognizing Tables (Chinookdb)
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/model/chinook.dart:
    SQFENTITY_GEN.DART: recognizing Tables (Chinookdb)
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/model/model.dart:
    -------------------------------------------------------FormBuilder: SqfEntityTable
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/model/model.dart:
    SQFENTITY_GEN.DART: recognizing Sequences (null)
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/model/model.dart:
    SQFENTITY_GEN.DART: recognizing Tables (MyDbModel)
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/model/model.dart:
    SQFENTITY_GEN.DART: recognizing Tables (MyDbModel)
    [INFO] 1m 17s elapsed, 31/33 actions completed.
    [INFO] Running build completed, took 1m 18s
    
    [INFO] Caching finalized dependency graph...
    [INFO] Caching finalized dependency graph completed, took 198ms
    
    [SEVERE] Failed after 1m 19s
    pub finished with exit code 1
    
    opened by Eric-Dev-Live 35
  • Desktop Support

    Desktop Support

    Is there any plan for desktop support? This is a really amazing library, and it would be awesome if it could be used on all platforms supported by flutter.

    help wanted 
    opened by ReniDelonzek 34
  • Build runner V1.5.0-nullsafety.0+1 error

    Build runner V1.5.0-nullsafety.0+1 error

    Hello bro,

    I am using

    sqfentity: ^1.5.0-nullsafety.0
    sqfentity_gen: ^1.5.0-nullsafety.0+1
    

    it fails and gives me the error:

    Null check operator used on a null value
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/Models/model.dart:
    -------------------------------------------------------FormBuilder: SqfEntityTable
    [WARNING] sqfentity_gen:property_sqfentity_forms on lib/Models/model.dart:
    SQFENTITY_GEN.DART: recognizing Tables (CannulaAppdb)
    [SEVERE] sqfentity_gen:property_sqfentity_forms on lib/Models/model.dart:
    
    Null check operator used on a null value
    [INFO] Running build completed, took 17.2s
    
    [INFO] Caching finalized dependency graph...
    [INFO] Caching finalized dependency graph completed, took 39ms
    
    [SEVERE] Failed after 17.3s
    pub finished with exit code 1
    
    
    opened by a7mdragab 27
  • FileSystemException

    FileSystemException

    import existing database and generate model automatically throw this exception on convertDatabaseToModelBase function. Exception has occurred. FileSystemException (FileSystemException: Cannot open file, path = '/data/data/com.example.fitness_flutter/databases/calories.db' (OS Error: No such file or directory, errno = 2))

    20

    opened by master11641 25
  • new iOS Error after upgrading to SQFEntity 1.1.1

    new iOS Error after upgrading to SQFEntity 1.1.1

    After upgrading and changing the code to work again all works fine (except the test issue #23) on Android, on iOS however, I do get an error in Xcode in file FMDatabase.m line 893, evaluating the return arguments from a query

    ` else {

        while (idx < queryCount) {
            
            if (arrayArgs && idx < (int)[arrayArgs count]) {
                obj = [arrayArgs objectAtIndex:(NSUInteger)idx];
            }
            else if (args) {
                obj = va_arg(args, id); **<--EXC_BAD_ACCESS (code=1, address=0x20)**
            }
            else {
                //We ran out of arguments
                break;
            }
            
            if (_traceExecution) {
                if ([obj isKindOfClass:[NSData class]]) {
                    NSLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]);
                }` 
    

    The relevant variable values are: args = (va_list) "\x15" idx = (int) 0 queryCount = (int) 1 obj = (id) 0x0

    The runner windows shows, that it happens during a call in the following flutter package:

    (lldb) #10 0x00000001030e76f0 in __40-[SqflitePlugin handleQueryCall:result:]_block_invoke at /Users/marcel/.pub-cache/hosted/pub.dartlang.org/sqflite-1.1.6+4/ios/Classes/SqflitePlugin.m:376

    This problem came with the new version, and I have no clue, how to debug this...

    opened by hellowtisch 23
  • Multiple issues with Migration

    Multiple issues with Migration

    // [STACKTRACE]
    
    I/flutter (15575): init() -> tableName:accounts
    I/flutter (15575): init() -> tableName:transactions
    I/flutter (15575): init() -> tableName:transaction_metas
    I/1.gpu   (15575): type=1400 audit(0.0:237124): avc: denied { ioctl } for path="/dev/kgsl-3d0" dev="tmpfs" ino=14787 ioctlcmd=945 scontext=u:r:untrusted_app:s0:c42,c257,c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
    I/flutter (15575): SQFENTITIY: alterTableQuery => [ALTER TABLE transactions ADD COLUMN SourceAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountSourceAccount ON transactions (SourceAccount ASC), ALTER TABLE transactions ADD COLUMN EffectiveSourceAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountEffectiveSourceAccount ON transactions (EffectiveSourceAccount ASC), ALTER TABLE transactions ADD COLUMN TransferDestinationAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountTransferDestinationAccount ON transactions (TransferDestinationAccount ASC), ALTER TABLE transactions ADD COLUMN TransferEffectiveDestinationAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountTransferEffectiveDestinationAccount ON transactions (TransferEffectiveDestinationAccount ASC), ALTER TABLE transactions ADD COLUMN type text]
    I/flutter (15575): SQFENTITIY: alterTableQuery => [ALTER TABLE transactions ADD COLUMN SourceAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountSourceAccount ON transactions (SourceAccount ASC), ALTER TABLE transactions ADD COLUMN EffectiveSourceAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountEffectiveSourceAccount ON transactions (EffectiveSourceAccount ASC), ALTER TABLE transactions ADD COLUMN TransferDestinationAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountTransferDestinationAccount ON transactions (TransferDestinationAccount ASC), ALTER TABLE transactions ADD COLUMN TransferEffectiveDestinationAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountTransferEffectiveDestinationAccount ON transactions (TransferEffectiveDestinationAccount ASC), ALTER TABLE transactions ADD COLUMN type text]
    I/flutter (15575): SQFENTITIY: Table named [transactions] was initialized successfully (Added new columns)
    I/flutter (15575): SQFENTITIY: alterTableQuery => [ALTER TABLE transactions ADD COLUMN SourceAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountSourceAccount ON transactions (SourceAccount ASC), ALTER TABLE transactions ADD COLUMN EffectiveSourceAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountEffectiveSourceAccount ON transactions (EffectiveSourceAccount ASC), ALTER TABLE transactions ADD COLUMN TransferDestinationAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountTransferDestinationAccount ON transactions (TransferDestinationAccount ASC), ALTER TABLE transactions ADD COLUMN TransferEffectiveDestinationAccount integer, CREATE INDEX IF NOT EXISTS IDXAccountTransferEffectiveDestinationAccount ON transactions (TransferEffectiveDestinationAccount ASC), ALTER TABLE transactions ADD COLUMN type text]
    I/flutter (15575): SQFENTITIY: Table named [transactions] was initialized successfully (Added new columns)
    E/SQLiteLog(15575): (1) duplicate column name: SourceAccount
    I/flutter (15575): Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction
    I/flutter (15575): Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction
    I/flutter (15575): SQFENTITY ERROR while run execSQLList:
    I/flutter (15575): DatabaseException(duplicate column name: SourceAccount (code 1 SQLITE_ERROR): , while compiling: ALTER TABLE transactions ADD COLUMN SourceAccount integer) sql 'ALTER TABLE transactions ADD COLUMN SourceAccount integer' args []}
    E/flutter (15575): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Exception: SQFENTITIY: DATABASE INITIALIZE ERROR The primary key name '_id' for table named [accounts] must be in [id]
    E/flutter (15575): #0      SqfEntityModelProvider.initializeDB (package:sqfentity/sqfentity.dart:585:13)
    E/flutter (15575): <asynchronous suspension>
    E/flutter (15575): #1      SqfEntityProvider.db (package:sqfentity/sqfentity.dart:63:22)
    E/flutter (15575): <asynchronous suspension>
    E/flutter (15575): #2      SqfEntityProvider.execDataTable (package:sqfentity/sqfentity.dart:212:36)
    E/flutter (15575): #3      SqfEntityModelProvider.initializeDB (package:sqfentity/sqfentity.dart:573:14)
    E/flutter (15575): #4      main (package:expense/main.dart:25:21)
    E/flutter (15575): #5      _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:45:6)
    E/flutter (15575): #6      main (package:expense/main.dart:13:18)
    E/flutter (15575): #7      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:239:25)
    E/flutter (15575): #8      _rootRun (dart:async/zone.dart:1126:13)
    E/flutter (15575): #9      _CustomZone.run (dart:async/zone.dart:1023:19)
    E/flutter (15575): #10     _runZoned (dart:async/zone.dart:1518:10)
    E/flutter (15575): #11     runZoned (dart:async/zone.dart:1502:12)
    E/flutter (15575): #12     _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:231:5)
    E/flutter (15575): #13     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)
    E/flutter (15575): #14     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
    

    Issue 1 - SourceAccount column for Transactions table alter request is called multiple times (2-3 (random but > 1) times as of logs and debug controls)

    Issue 2 - DATABASE INITIALIZE ERROR The primary key name '_id' for table named [accounts] must be in [id]

    Note - For issue 2, I wen't through #52. I investigated and completely uninstalled the app and re-ran the debug, still received this message.

    /// Table schemas - 
    
    // Account
    const account = SqfEntityTable(
      tableName: 'accounts',
      modelName: 'Account',
      primaryKeyName: 'id',
      primaryKeyType: PrimaryKeyType.integer_auto_incremental,
      fields: [
        SqfEntityField("name", DbType.text),
        SqfEntityField("balance", DbType.real, defaultValue: 0.0),
        SqfEntityFieldRelationship(
          fieldName: 'ParentAccount',
          deleteRule: DeleteRule.NO_ACTION,
          relationType: RelationType.ONE_TO_ONE,
        )
      ],
    );
    
    
    // Transaction
    const transaction = SqfEntityTable(
      tableName: 'transactions',
      modelName: 'Transaction',
      primaryKeyName: 'id',
      primaryKeyType: PrimaryKeyType.integer_auto_incremental,
      fields: [
        SqfEntityFieldRelationship(
          parentTable: account,
          fieldName: 'SourceAccount',
          relationType: RelationType.ONE_TO_MANY,
          deleteRule: DeleteRule.NO_ACTION,
        ),
        SqfEntityFieldRelationship(
          parentTable: account,
          fieldName: 'EffectiveSourceAccount',
          relationType: RelationType.ONE_TO_MANY,
          deleteRule: DeleteRule.NO_ACTION,
        ),
        SqfEntityFieldRelationship(
          parentTable: account,
          fieldName: 'TransferDestinationAccount',
          relationType: RelationType.ONE_TO_MANY,
          deleteRule: DeleteRule.NO_ACTION,
        ),
        SqfEntityFieldRelationship(
          parentTable: account,
          fieldName: 'TransferEffectiveDestinationAccount',
          relationType: RelationType.ONE_TO_MANY,
          deleteRule: DeleteRule.NO_ACTION,
        ),
        SqfEntityField('amount', DbType.real),
        SqfEntityField('balance', DbType.real),
        SqfEntityField('registeredAt', DbType.datetime),
        SqfEntityField('type', DbType.text),
      ],
    );
    
    
    // Transaction Meta
    const transactionMeta = SqfEntityTable(
      tableName: 'transaction_metas',
      modelName: 'TransactionMeta',
      primaryKeyName: 'id',
      primaryKeyType: PrimaryKeyType.integer_auto_incremental,
      fields: [
        SqfEntityField("description", DbType.text),
        SqfEntityField("happenedAt", DbType.datetime),
        SqfEntityFieldRelationship(
          parentTable: transaction,
          fieldName: "Transaction",
          relationType: RelationType.ONE_TO_ONE,
          deleteRule: DeleteRule.NO_ACTION,
        ),
      ],
    );
    
    
    opened by vaishnavmhetre 20
  • SaveAll still throwing errors

    SaveAll still throwing errors

    Hi @hhtokpinar I am sorry for being late for the previous thread. I couldn't login.

    When using fetchFromUrl the saveAll(), gives the error

    E/SQLiteLog(18752): (20) statement aborts at 6: [INSERT OR REPLACE INTO users_table (user_id,user_name)  VALUES (?,?,?)] datatype mismatch
    

    for all.

    Thanks.

    opened by a7mdragab 19
  • save() method doesn't update records

    save() method doesn't update records

    I am using sqfentity 2.3.0+5 package for my mobile app to store local data. In the documentation it says that save() method can be used for both updating and inserting but when I insert some data with save() method I can not update it after using again save() method.

    Here is the example usage of it:

    await ClubData( id: data[i]['id'], isUnlocked: 0, currentLevel: 1, totalLevel: data[i]['players'].length, logoURL: data[i]['logoURL'], points: 0, name: data[i]['name']) .save();

    Let's say that data[i]['players'].length is equal to 10 and I insert the data using save() method for the first time. Then data[i]['players'].length increases and I use the same method again but totalLevel doesn't update. What am I doing wrong? Can you help me?

    opened by melikbozkurt 0
  • toDropDownMenu Method

    toDropDownMenu Method

    Is there a way to invoke the "toDropDownMenu" method after getting the result of the "toList" method?

    Something similar to this:

    List<test> objects = await test().select().toList();
    
    Then: 
    
    List<DropdownMenuItem<test>> dropDownMenuItems = objects.toDropDownMenu();
    
    opened by GoedertDalmolin 1
  • Fail to initialize on Windows

    Fail to initialize on Windows

    When initializing the database using this package, it will throw an "File not found" error.

    Although this could be fixed by modifying the package to create database file first, but why the db path is located in the .dart_tool folder, not in app's data folder ?

    Here is the stack trace.

    [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: FileSystemException: Cannot open file, path = 'D:\l\Desktop\script\flutter\test1\.dart_tool\sqflite_common_ffi\databases\word.db' (OS Error: 系统找不到指定的路径。
    
    , errno = 3)
    #0      SqfEntityConnectionFfi.writeDatabase (package:sqfentity/sqfentity_connection_ffi.dart:55)
    <asynchronous suspension>
    #1      SqfEntityConnectionFfi.openDb.<anonymous closure> (package:sqfentity/sqfentity_connection_ffi.dart:80)     #1      SqfEntityConnectionFfi.openDb.<anonymous closure> (package:sqfentity/sqfentity_connection_ffi.dart:80)     
    <asynchronous suspension>
    #2      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33)
    <asynchronous suspension>
    #3      SqfEntityConnectionFfi.openDb (package:sqfentity/sqfentity_connection_ffi.dart:64)
    <asynchronous suspension>
    #4      SqfEntityProvider.db (package:sqfentity/sqfentity.dart:74)
    <asynchronous suspension>
    #5      SqfEntityProvider.execDataTable (package:sqfentity/sqfentity.dart:167)
    <asynchronous suspension>
    #6      SqfEntityModelProvider.initializeDB (package:sqfentity/sqfentity.dart:578)
    <asynchronous suspension>
    
    opened by Tangent-90 0
  • Apparent infinite loop with many to many relationship and preload: true

    Apparent infinite loop with many to many relationship and preload: true

    If I query a table with a many-to-many relationship and use .toList(preload: true), the query never returns if retrieving a record with related records. It looks like it gets stuck in an infinite loop.

    A simplified version of my model for example:

    const tableImage = SqfEntityTable(
        tableName: 'image',
        primaryKeyName: 'id',
        primaryKeyType: PrimaryKeyType.integer_auto_incremental,
        useSoftDeleting: false,
        modelName: null,
        fields: [
          SqfEntityField('fileName', DbType.text),
        ]);
    
    const tableAlbums = SqfEntityTable(
        tableName: 'album',
        primaryKeyName: 'id',
        primaryKeyType: PrimaryKeyType.integer_auto_incremental,
        useSoftDeleting: false,
        modelName: null,
        fields: [
          SqfEntityField('name', DbType.text),
    
          SqfEntityFieldRelationship(
            parentTable: tableImage,
            relationType: RelationType.MANY_TO_MANY,
            manyToManyTableName: "albumImage",
            deleteRule: DeleteRule.CASCADE,
          )
        ])
    

    then for example if I run:

    return await Image().select().toList(preload: true); // <- never returns
    
    opened by JWambaugh 0
  • Requirement of `tryParseDateTime` etc not mentioned in documentation

    Requirement of `tryParseDateTime` etc not mentioned in documentation

    Builds now fail unless these functions are defined in the model, yet there's no mention of them in the documentation:

    final defaultDateFormat = intl.DateFormat('dd-MMMM-yyyy');
    
    /// Specify a defaultTimeFormat (Optional) default (hh:mm a)
    final defaultTimeFormat = intl.DateFormat('hh:mm a');
    
    /// Specify a defaultDateTimeFormat (Optional) default (dd-MM-yyyy - hh:mm a)
    final defaultDateTimeFormat = intl.DateFormat('$defaultDateFormat - $defaultTimeFormat');
    
    DateTime toDateTime(TimeOfDay x) {
      return DateTime(2020, 1, 1, x.hour, x.minute);
    }
    
    TimeOfDay? tryParseTime(String x) {
      final DateTime? d = tryParseTimeToDate(x);
      return d == null ? null : TimeOfDay.fromDateTime(d);
    }
    
    DateTime? tryParseTimeToDate(String x) {
      try {
        return int.tryParse(x) != null ? DateTime.fromMillisecondsSinceEpoch(int.tryParse(x)!) : defaultTimeFormat.parse(x);
      } catch (e) {
        return tryParseDateTime(x);
      }
    }
    
    DateTime? tryParseDate(String x) {
      try {
        return defaultDateFormat.parse(x);
      } catch (e) {
        return tryParseDateTime(x);
      }
    }
    
    DateTime? tryParseDateTime(String x) {
      try {
        return defaultDateTimeFormat.parse(x);
      } catch (e) {
        return DateTime.tryParse(x);
      }
    }
    
    opened by JWambaugh 7
Owner
Hüseyin Tokpınar
Software Engineer
Hüseyin Tokpınar
Note app flutter sqflite provider - A Note Taking Application written in Flutter

note_app_flutter_sqflite_provider ?? Introduce This is a note taking app made wi

Cool Kid 10 Dec 22, 2022
A starter kit for beginner learns with Bloc pattern, RxDart, sqflite, Fluro and Dio to architect a flutter project. This starter kit build an App Store app as a example

Flutter Starter Kit - App Store Example A starter kit for beginner learns with Bloc pattern, RxDart, sqflite, Fluro and Dio to architect a flutter pro

kw101 678 Jan 8, 2023
Visually manage your Flutter Sqflite database

Flutter Sqflite Manager To manage your sqflite database in Flutter. Browse the database's tables, see the rows inside them, empty tables and delete th

Mattia Crovero 39 Nov 5, 2022
This is an application that uses the Flutter framework, SQFLite as a database to record blood pressure, blood sugar, BMI, or create medication reminders in multi mobile platforms You can run this project on iOS, Android

This is an application that uses the Flutter framework, SQFLite as a database to record blood pressure, blood sugar, BMI, or create medication reminders in multi mobile platforms You can run this project on iOS, Android

null 14 Dec 29, 2022
Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent.

Polymaker Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent. Ins

Yusril Rapsanjani 15 Apr 17, 2022
Note provider - Note App using Provider state management, Sqflite and Localization for two language Arabic and English.

note_provider Sqflite with provider statemanagement Getting Started This project is a starting point for a Flutter application. A few resources to get

Mohanned Anwar 0 Jan 1, 2022
Movie App used MVC pattern, Getx for state managment, sqflite for backend database

movie_app A new Flutter application. Getting Started This project used MVC pattern, Getx for state managment, sqflite for backend database, firebase/W

HM Badhon 3 Sep 13, 2022
A Clean looking modren and colorful notes app using a local database with sqflite

A Clean looking modren and colorful notes app using a local database with sqflite

Moaz Talaat 3 Sep 23, 2022
simple note application using Flutter ,Dart and SQLite database

note_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

nirmalnyure 3 Feb 15, 2022
Aplicativo desenvolvido em sala de aula com auxilio do Profº Kleber Andrade, utilizando Flutter e Sqlite.

App Lista de Tarefas Aplicativo desenvolvido apartir de um exercicio proposto pelo professor kleber Andrade. Objetivo era fazer uma lista de tarefas c

Otavio Freire 0 Dec 27, 2021
A note keeper created using Flutter and sqlite

note_keeper This is a note keeper created using flutter and sqlite. Getting Started This project is a starting point for a Flutter application. A few

Amine Elmouradi 14 Feb 13, 2022
A shopper Flutter app that use BloC pattern and CRUD operations with different ways(memory/sqlite/http)

The project is maintained by a non-profit organisation, along with an amazing collections of Flutter samples. We're trying to make continuous commits

Flutter Samples 80 Nov 10, 2022
Note Taking App made with Flutter with Sqlite as database..

Note Taking App made in Flutter with Sqlite database This is a note taking app made with flutter. Concepts used: Sqlite database to store custom Note

Bibek Timsina 351 Dec 24, 2022
Time do - A Flutter Todo Application Using GetX And Sqlite

time_do A TODO Flutter project. Getting Started Flutter application -Design Patt

Ahmed Khaled 12 Oct 11, 2022
The typesafe, reactive, and lightweight SQLite abstraction for your Flutter applications

See the project's website for the full documentation. Floor provides a neat SQLite abstraction for your Flutter applications inspired by the Room pers

Vitus 786 Dec 28, 2022
Small Flutter app that uses SQLite to persist data.

Crud_With_Flutter_And_Sqlite A new Flutter project. The application allows you to register a user with your name and email, edit and also delete. All

Idelfonso Joás 0 Oct 22, 2022
Criando meu primeiro aplicativo completo com o Flutter, utlizando sqlite, provider, firebase e implementando google login..

Todo list App Projeto de estudo de flutter em andamento... Conteudos aqui! Sobre o projeto Tecnologias usadas Demonstração Tela de login Tela de cadas

Gustavo Andrade 4 Nov 25, 2022
Raden Saleh 20 Aug 12, 2023
Raden Saleh 53 Jul 27, 2023