DatabaseClient class

Client for database operations

Constructors

DatabaseClient({required String baseUrl, required TokenStorage tokenStorage, Client? httpClient, Duration timeout = const Duration(seconds: 30), Map<String, String>? headers})
Creates a new DatabaseClient instance

Properties

baseUrl String
Base URL of the database service
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
Request timeout duration
final
tokenStorage TokenStorage
Token storage
final

Methods

aggregate(String collection, List<Map<String, dynamic>> pipeline) Future<List<Map<String, dynamic>>>
Runs an aggregation pipeline
count(String collection, {Map<String, dynamic>? filter}) Future<int>
Counts documents
createCollection(String name) Future<void>
Creates a new collection
delete(String collection, String id) Future<void>
Deletes a document
deleteCollection(String name) Future<void>
Deletes a collection
findOne(String collection, {Map<String, dynamic>? filter}) Future<Map<String, dynamic>?>
Finds one document
getById(String collection, String id) Future<Map<String, dynamic>?>
Gets a document by ID
insert(String collection, Map<String, dynamic> document) Future<Map<String, dynamic>>
Inserts a document
insertMany(String collection, List<Map<String, dynamic>> documents) Future<List<Map<String, dynamic>>>
Inserts multiple documents
listCollections() Future<List<String>>
Lists all collections
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query(String collection, {Map<String, dynamic>? filter, Map<String, int>? sort, int? limit, int? skip}) Future<QueryResult<Map<String, dynamic>>>
Queries documents
queryBuilder(String collection, QueryBuilder builder) Future<QueryResult<Map<String, dynamic>>>
Queries with a builder
sql(String query) Future<SqlQueryResult>
Executes a SQL-like query (BaaSQL)
sqlBuilder() SqlBuilder
Creates a SQL query builder for fluent query construction
toString() String
A string representation of this object.
inherited
update(String collection, String id, Map<String, dynamic> updates) Future<Map<String, dynamic>>
Updates a document
validateSql(String query) Future<SqlValidationResult>
Validates a SQL query without executing it

Operators

operator ==(Object other) bool
The equality operator.
inherited