store method

Future<int> store([
  1. MP? m
])
inherited

Implementation

Future<int> store([MP? m]) async {
  if (kind == FKind.tmp) return 0;
  if (storedAt > 0) return this.id;
  if (storing != null) return storing!;
  MP mp = {
    ...toMap(),
    ...?m,
    'stored_at': unixSeconds,
  };
  if (mp['id'] case int id) return id;

  //mp.remove('id');
  final id = mp['id'] = ++db.lastId;
  final isOk = await ctrl.store(mp);
  if (!isOk) return 0;
  this.id = id;
  storage[id] = this;
  return id;
}