refresh method

Future<void> refresh()
inherited

Refresh the model from the database.

Implementation

Future<void> refresh() async {
  if (!exists) return;

  final fresh = await query.where(primaryKey, '=', getKey()).first();
  if (fresh != null) {
    if (this is HasAttributes) {
      if (fresh is HasAttributes) {
        (this as HasAttributes).fromJson((fresh as HasAttributes).attributes);
      }
    }
  }
}