fetch abstract method
Retrieves multiple items from the database based on the provided (optional) filters.
The query
is list of DetaQuery. If omitted, you will get all the
items in the database (up to 1mb or max 1000 items).
The limit
of the number of items you want to retreive, min value is 1.
The last
key seen in a previous paginated response.
Throw DetaException
if a query is made on the key or
limit
is less than 1.
Example:
final result await deta.base('my_base').fetch(
query: [DetaQuery('name').equalTo('Jhon')],
);
If you have a complex object which contains more objects, and you want to do the search by the parameters of the object that is inside another one, you can access it in a hierarchical way.
Object User:
{
"key": "user-a",
"user": {
"username": "bev",
"profile": {
"age": 22,
"active": true,
"name": "Beverly"
},
"likes":["anime", "ramen"],
"purchases": 3
}
}
You can search by name
and age
in profile
object like this:
final result await deta.base('my_base').fetch(
query: [
DetaQuery('user.profile.age')
.equalTo(22).and('user.profile.name').equalTo('Beverly'),
], limit: 10,
);
Implementation
Future<Map<String, dynamic>> fetch({
List<DetaQuery> query = const [],
int limit = 1000,
String last = '',
});