database_query_builder 0.0.2 database_query_builder: ^0.0.2 copied to clipboard
The Database Query Builder for Dart provides an easy, efficient, and fluid interface for building or running database queries.
Database: Query Builder
# Introduction #
The Database Query Builder for Dart provides an easy, efficient, and fluid interface for building or running database queries. It can be used to perform most basic (Temporary) database operations and works perfectly with postgresql we hope to add support for other managers later.
This project will momentarily depend on our source postgres library to connect to this manager and execute queries, although it is true, there are multiple ORM-based libraries, but we want to do something of our own, something CRAZY!
Data Methods #
We have several methods to bring information from our queries:
get()
Returns a list of type map<String,dynamic> depending on our queries
getModel()
Returns a list of a strongly typed class to generate direct models
ToSql()
gets the query generated by the query builder does not require a database connection, you can use this function to generate the required SQL helping you avoid SQL injections
Basic Query #
DB.table('products').get();
DB.table('products').getModel<Product>(Product.fromJson);
DB.table('products').first();
DB.table('products').firstModel();
DB.table('products').toSql();
Inserts #
Provides an INSERT
method that can be used to insert records into the database table
final numRowAffected = await DB.table('persons').insert({
'nombre': 'Nuevo User 1212',
'apellido': 'Rolda 12121',
'edad': 666,
}).save()
Select Statements
Raw Expressions
Joins
===> Join
===> leftJoin
===> rightJoin
===> crossJoin
Unions
Delete
Ordering, Grouping, Limit
where
===> Where Clauses
===> Where IN
===> Where OR
===> Where NULL
===> Where EXIST
===> Where NOT EXIST
FEATURE #
Methods | Status |
Insert | ✅ |
InsertMultiple | ✅ |
insertGetId | ❌ |
Update | ✔️ |
UpdateOrInsert | ❌ |
Where | ✅ |
Where nested | ✔️ |
Where IN | ❌ |
Where OR | ❌ |
whereNull | ❌ |
orderBy | ✔️ |
groupBy | ✔️ |
limit | ✔️ |
Join | ❌ |
LeftJoin | ❌ |
RightJoin | ❌ |
CrossJoin | ❌ |
Drop Table | ❌ |
Truncate Table | ❌ |
Increment | ❌ |
Decrement | ❌ |
Max | ❌ |
Min | ❌ |
Count | ❌ |
Avg | ❌ |
Sum | ❌ |
Exists | ❌ |
DoesntExist | ❌ |