update method
Future<RecordModel>
update(
- String id, {
- Map<
String, dynamic> body = const {}, - Map<
String, dynamic> query = const {}, - List<
MultipartFile> files = const [], - Map<
String, String> headers = const {}, - String? expand,
- String? fields,
override
Updates a single record model by its id.
If the current AuthStore.model matches with the updated id, then on success the client AuthStore will be updated with the result model.
Implementation
@override
Future<RecordModel> update(
String id, {
Map<String, dynamic> body = const {},
Map<String, dynamic> query = const {},
List<http.MultipartFile> files = const [],
Map<String, String> headers = const {},
String? expand,
String? fields,
}) {
return super
.update(
id,
body: body,
query: query,
files: files,
headers: headers,
expand: expand,
fields: fields,
)
.then((item) {
if (client.authStore.model != null &&
client.authStore.model is RecordModel &&
(client.authStore.model as RecordModel).id == item.id &&
[
(client.authStore.model as RecordModel).collectionId,
(client.authStore.model as RecordModel).collectionName,
].contains(_collectionIdOrName)) {
client.authStore.save(client.authStore.token, item);
}
return item;
});
}