diff --git a/docs/0.9.10.html b/docs/0.9.10.html index 699783298..64f522a7d 100644 --- a/docs/0.9.10.html +++ b/docs/0.9.10.html @@ -4,7 +4,7 @@
To batch update several rows use the update
method.
var companies = await Company.db.find(session);
companies = companies.map((c) => c.copyWith(name: 'New name')).toList();
var updatedCompanies = await Company.db.update(session, companies);
This is an atomic operation, meaning no entries will be updated if any entry fails to be updated. The update
method returns a List
of the updated objects.
It is possible to target one or several columns that you want to mutate, meaning any other column will be left unmodified even if the dart object has introduced a change.
+Update a single row, the following code will update the company name, but will not change the address column.
+var company = await Company.db.findById(session, companyId);
company.name = 'New name';
company.address = 'Baker street'
var updatedCompany = await Company.db.updateRow(session, company, columns: [Company.t.name]);
The same syntax is available for multiple rows.
+var companies = await Company.db.find(session);
companies = companies.map((c) => c.copyWith(name: 'New name', address: 'Baker Street')).toList();
var updatedCompanies = await Company.db.update(session, companies, columns: [Company.t.name]);
Deleting rows from the database is done in a similar way to updating rows. However, there are three delete operations available.
Count is a special type of query that helps counting the number of rows in the database that matches a specific filter.
var count = await Company.db.count(
session,
where: (t) => t.name.like('s%'),
);
The return value is an int
for the number of rows matching the filter.
The return value is an int
for the number of rows matching the filter.