Insert into MongoDB - Only allows msg.payload object

I am having an issue inserting something other than the msg.payload object into Mongo. I have a JSON object I am trying to insert. I Convert and Format the Object to a JSON string and then insert it into Mongo, however I am getting the error message "RangeError: Maximum call stack size exceeded".

To test, I copied the output JSON string and did a document insert straight from Robomongo. It inserted correctly. It seems to just be an issue with how the Node-Red insert is working. Any help would be much appreciated! Note, that just turning on insert msg.payload works perfect, it is just not Keyed correctly in the database( See SS) NodeRedErros|302x424

Try sending the JSON string inside an array [ {JSON} ]

Thanks @ghayne that works. It is still entering the string as a payload key in the DB (see screenshot). Is this node designed to enter things other than message payload?

It might be easier to answer your question if you specified which node you are using https://flows.nodered.org/?term=mongodb&type=node&num_pages=1

Sure, I am using:


Version 0.0.14

From the node info:

" MongoDB only accepts objects.

Save and insert can either store msg or msg.payload . If msg.payload is selected it should contain an object. If not it will be wrapped in an object with a name of payload."

1 Like

@ghayne made a good point, it looks like this node is really just made to input msg.payload values. After years of being in the industry, i should have learned how to read documentation by now.

I just corrected the issue here is how I did it:
There is another node, node-red-contrib-mongodb3 which allows for many more operations to be carried out on the database. By using this and just passing a JSON string, I was able to input my data correctly

Hope this helps some other people, in short, just use node-red-contrib-mongodb3 if you want to carry out operations in Mongo.

2 Likes

Hmmm...what a novel Idea :rofl:

It'll never catch on...

1 Like

A universal truth! Except for old Hewlett Packard calculator manuals, which are things of beauty.

Didn't they use reverse Polish notation ? which would need a very good manual !

I still use RPN! Unfortunately I sold my HP41C, and my beloved HP71B, which was my introduction to BASIC programming. Now reduced to a HP15C Android app.