package builder // UnwindOption is a functional option for configuring the $unwind stage. type UnwindOption func(*UnwindOpts) type UnwindOpts struct { PreserveNullAndEmptyArrays bool IncludeArrayIndex string } // WithPreserveNullAndEmptyArrays tells $unwind to keep docs where the array is null/empty. func WithPreserveNullAndEmptyArrays() UnwindOption { return func(o *UnwindOpts) { o.PreserveNullAndEmptyArrays = true } } // WithIncludeArrayIndex adds an array‐index field named idxField to each unwound doc. func WithIncludeArrayIndex(idxField string) UnwindOption { return func(o *UnwindOpts) { o.IncludeArrayIndex = idxField } }