updateFeedPropertiesCount method
Future<void>
updateFeedPropertiesCount(
{ - required String feedId,
- int reactionsCount = 0,
- int repliesCount = 0,
- int savesCount = 0,
- int sharesCount = 0,
- int viewsCount = 0,
})
Implementation
Future<void> updateFeedPropertiesCount({
required final String feedId,
final int reactionsCount = 0,
final int commentsCount = 0,
final int repliesCount = 0,
final int savesCount = 0,
final int sharesCount = 0,
final int viewsCount = 0,
}) async {
try {
final _feedRef = PeamanReferenceHelper.feedsCol.doc(feedId);
final _data = <String, dynamic>{
'reactions_count': FieldValue.increment(reactionsCount),
'comments_count': FieldValue.increment(commentsCount),
'replies_count': FieldValue.increment(repliesCount),
'saves_count': FieldValue.increment(savesCount),
'shares_count': FieldValue.increment(sharesCount),
'views_count': FieldValue.increment(viewsCount),
};
await _feedRef.update(_data);
print('Success: Updating feed properties count of $feedId');
} catch (e) {
print(e);
print('Error!!!: Updating feed properties count of $feedId');
return null;
}
}