Database class
Provides direct SQLite database access with no restrictions.
The Database class allows you to execute raw SQL queries against your Calljmp database. This gives you complete control over your data with full SQLite functionality including complex queries, joins, transactions, and schema modifications.
Security
Database queries are executed with the permissions of the authenticated user. The system enforces access control based on user roles and tags, ensuring that users can only access data they are authorized to see.
Usage
final calljmp = Calljmp();
// Simple SELECT query
final users = await calljmp.database.query(
sql: 'SELECT id, email, name FROM users WHERE active = ?',
params: [true],
);
// INSERT query
final result = await calljmp.database.query(
sql: 'INSERT INTO posts (title, content, user_id) VALUES (?, ?, ?)',
params: ['My Title', 'Post content', 123],
);
print('Inserted post with ID: ${result.insertId}');
// Complex query with joins
final posts = await calljmp.database.query(
sql: '''
SELECT p.id, p.title, u.name as author_name
FROM posts p
JOIN users u ON p.user_id = u.id
WHERE p.created_at > ?
ORDER BY p.created_at DESC
''',
params: [DateTime.now().subtract(Duration(days: 7)).toIso8601String()],
);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
observe<
T> (String table) → DatabaseObserver< T> - Observe database changes for a specific table with type safety.
-
query(
{required String sql, List? params}) → Future< ({int? insertId, int? numAffectedRows, List rows})> - Executes a SQL query against the database.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited