MongoDB Insert key/value formatting

Hi there, probably something simple, but I can’t work it out, so hopefully someone can help.

Trying to format a MongoDB Insert correctly, using json data from the previous node in the expression, but it seems that my key (“errortype”) and value (“Bounce”) are being stored as the key in the node output json (and mongo) - the value is always just “null”.

[
 {
  ""errortype" : Bounce": null,
  "_id": "605c8043ba2ad800db77b164",
  "id": "605c8043ba2ad800db77b164"
 }
]

My full node below. Thanks in advance if anyone can help!

{
  "nodes": [
    {
      "parameters": {
        "operation": "insert",
        "collection": "email-sns-notifications",
        "fields": "=\"errortype\" : {{$node[\"To Flow Data\"].json[\"notificationType\"]}}"
      },
      "name": "MongoDB",
      "type": "n8n-nodes-base.mongoDb",
      "typeVersion": 1,
      "position": [
        920,
        70
      ],
      "credentials": {
        "mongoDb": "mongo"
      }
    }
  ],
  "connections": {}
}

Hey @richmarks20, welcome to the community. It is lovely to see you here :raised_hands:

Perhaps this might be useful for you? https://n8n.io/workflows/980

My colleague @maxT created this to explain how one can insert data into databases and spreadsheets using n8n. Let me know if you run into any other blockers and I’d be happy to help :slight_smile:

1 Like