readStorageObject method
Reading storage objects
Define a class that describes the storage object and create a new storage object id with the collection name, key and user id. Finally, read the storage objects and parse the JSON data:
Implementation
@override
Future<model.StorageObject?> readStorageObject({
required model.Session session,
String? collection,
String? key,
String? userId,
}) async {
final res = await _client.readStorageObjects(
api.ReadStorageObjectsRequest(
objectIds: [
api.ReadStorageObjectId(
collection: collection,
key: key,
userId: userId,
),
],
),
options: _getSessionCallOptions(session),
);
return res.objects.isEmpty
? null
: model.StorageObject.fromDto(res.objects.first);
}