create method

  1. @override
FutureOr<CreateDbResult> create(
  1. Access access
)
override

Implementation

@override
FutureOr<CreateDbResult> create(Access access) {
  if (access.data == null) {
    throw BadRequests();
  }
  String id;
  if (access.identifier == null &&
      access.data!["_id"] == null &&
      access.data!["id"] == null) {
    id = getRandomId(30);
    access.data!["_id"] = id;
  }
  id = access.identifier ?? access.data!["id"] ?? access.data!["_id"]!;
  data[access.collection] ??= {};
  data[access.collection]![id] = access.data!;
  return CreateDbResult(identifier: id);
}