getById method

Future<Map<String, Object?>?> getById(
  1. String id
)

Implementation

Future<Map<String, Object?>?> getById(String id) async {
  var oid = ObjectId.tryParse(id);

  if (oid == null || !await existId(id)) {
    return null;
  }

  var res = await collection.findOne(where.id(oid));
  if (res != null) {
    return toModel(res);
  }
  return null;
}