How to use Aggregate in AppSmith

518 Views Asked by At

In my database of MongoDB, I can't insert new register in the historial I want insert the phone and start date My model in Mongo is this

1

And the code what write is this

{
    "aggregate": "dids",
    "pipeline": [
        {
            "$match": {
                "_id": ObjectId({{sPhone.selectedOptionValue}})
            }
        }
    ],
    "cursor": {
        "batchSize": 10
    }
}

how insert $addFields in pipeline segment?

"$addFields": {
                "history.contract_id": {{tableOfContracts.selectedRow._id}},
                "history.start_date": {{dtpkStart.selectedDate}}
            }

Yes is written below the match segment, throws error ('A pipeline stage specification object must contain exactly one field')

Any solution?

1

There are 1 best solutions below

0
Felix Suarez On

To insert data, you can consult it in the appsmith documentation in the following links.

Link to the explanation of mongodb methods: https://www.mongodb.com/docs/manual/reference/insert-methods/

Link to query syntax: https://docs.appsmith.com/reference/datasources/querying-mongodb/mongo-syntax

Query configuration:enter image description here