Skip to content

Omit the aggregation stage when its parameter is empty/unset #1209

@zhangtemplar

Description

@zhangtemplar

For example, I have such endpoint:

{
    'datasource': {
        'source': 'project',
        'aggregation': {
            'pipeline': [
                {"$match": "$where"},
                {
                    "$lookup": {
                        "from": "user",
                        "localField": "creatorId",
                        "foreignField": "id",
                        "as": "creator",
                    },
                },
                {'$unwind': '$creator'},
                {'$match': "$extraWhere"},
                {"$sort": "$order"},
                {"$project": "$projection"}
            ]
        }
    }
}

Sometimes, I don't have $extraWhere provided. In this case, could eve simply remove this stage from the aggregation pipeline?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions