getById method

  1. @override
Future<T?> getById(
  1. Id id
)
override

Implementation

@override
Future<T?> getById(Id id) async {
  try {
    final doc = await config.databases.getDocument(
      databaseId: config.databaseId,
      collectionId: config.collectionId,
      documentId: config.idToString(id),
    );
    final data = Map<String, dynamic>.from(doc.data);
    return config.fromJson(data);
  } on aw.AppwriteException {
    // Not found or other error
    return null;
  }
}