unwind static method

Map<String, Object> unwind({
  1. required String path,
  2. String? as,
  3. bool? preserveNullAndEmptyArrays,
})

Implementation

static Map<String, Object> unwind({
  required String path,
  String? as,
  bool? preserveNullAndEmptyArrays,
}) {
  if (as == null && preserveNullAndEmptyArrays == null) {
    return {'\$unwind': "\$$path"};
  }

  return {
    '\$unwind': {
      'path': "\$$path",
      if (preserveNullAndEmptyArrays != null)
        'preserveNullAndEmptyArrays': preserveNullAndEmptyArrays,
      if (as != null) 'as': "$as"
    }
  };
}