toNegativeUpdateJson method

Map<String, dynamic> toNegativeUpdateJson()

Implementation

Map<String, dynamic> toNegativeUpdateJson() {
  final _extraData = Map<String, dynamic>.from(extraData);

  _extraData.removeWhere((key, value) => value is! FieldValue);

  final _data = <String, dynamic>{
    'searchKeys':
        searchKeys == null ? null : FieldValue.arrayRemove(searchKeys!),
    'feeds': feeds == null ? null : FieldValue.increment(-feeds!),
    'photos': photos == null ? null : FieldValue.increment(-photos!),
    'videos': videos == null ? null : FieldValue.increment(-videos!),
    'followers': followers == null ? null : FieldValue.increment(-followers!),
    'following': following == null ? null : FieldValue.increment(-following!),
    'reactions_received_from_feeds': reactionsReceivedFromFeeds == null
        ? null
        : FieldValue.increment(-reactionsReceivedFromFeeds!),
    'comments_received_from_feeds': commentsReceivedFromFeeds == null
        ? null
        : FieldValue.increment(-commentsReceivedFromFeeds!),
    'replies_received_from_feeds': repliesReceivedFromFeeds == null
        ? null
        : FieldValue.increment(-repliesReceivedFromFeeds!),
    'shares_received_from_feeds': sharesReceivedFromFeeds == null
        ? null
        : FieldValue.increment(-sharesReceivedFromFeeds!),
    'views_received_from_feeds': viewsReceivedFromFeeds == null
        ? null
        : FieldValue.increment(-viewsReceivedFromFeeds!),
    'onboarding_step': onboardingStep == null
        ? null
        : FieldValue.increment(-onboardingStep!),
    ..._extraData,
  };

  _data.removeWhere((key, value) => value == null);
  return _data;
}