skip to Main Content

Convert json pipeline to Aggify query

this is my pipeline , how can i convert this to Aggify query

I need to simplify some of my queries by using the aggify generator, which is a python package, so that it can be read and I can query faster. But I have problems in some parts, like this question, which is a bit complicated

Aggify : https://github.com/Aggify/aggify

pipeline = [
                {
                    '$match': {
                        'owner_id': ObjectId(account_id)
                    }
                }, {
                    '$lookup': {
                        'from': 'discussion',
                        'let': {
                            'id': '$_id'
                        },
                        'pipeline': [
                            {
                                '$match': {
                                    '$expr': {
                                        '$and': [
                                            {
                                                '$eq': [
                                                    '$parent_id', '$$id'
                                                ]
                                            }, {
                                                '$ne': [
                                                    '$owner_id', ObjectId(account_id)
                                                ]
                                            }
                                        ]
                                    }
                                }
                            }
                        ],
                        'as': 'replies'
                    }
                }
            ]

2

Answers


  1. Please give me the model which you want to aggregate on it.

    Login or Signup to reply.
  2. If you want to generate your raw Aggregation pipeline to python language.
    You can use MongoDB Compass.

    where you can export your raw query to any language supported format.

    It consist of options such as JAVA,Python3,NODE etc.

    Hope it helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search