# How to insert data via mongoDB Atlas?

**URL:** <https://discourse.nodered.org/t/how-to-insert-data-via-mongodb-atlas/68503>\
**Category:** General\
**Tags:** database\
**Created:** [3 October 2022 07:10 UTC](https://discourse.nodered.org/t/how-to-insert-data-via-mongodb-atlas/68503 "2022-10-03T07:10:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![choiprin0310](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@choiprin0310](https://discourse.nodered.org/u/choiprin0310)\
**Post date:** [3 October 2022 07:10 UTC](https://discourse.nodered.org/t/how-to-insert-data-via-mongodb-atlas/68503/1 "2022-10-03T07:10:37Z")

</div>

Hi, I'm trying to insert sample data in mongoDB Atlas.

-First, this is my funcion code which works very well in any other mongodb server.

```auto
var newMsg = {};
newMsg.collection = 'local';
newMsg.operation = 'insert';
newMsg.payload = {'test':msg.payload};
return newMsg;

```

  
-Second. I made sample data in my mongoDB Atlas already but  
can't upload over 2 img things in forum cause i'm new .   

Last one is my mongoDB2 node config.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/77981f752881d5addd59fa529414e2c81ec59d27.png)

I changed my username,password to \<[usename\>\<[password\>for security.

So all things are well-done. Now i'm trying to insert data with node-red  
but i can't make it with this error msg.

> "MongoError: (Unauthorized) not authorized on admin to execute command { insert: "local", documents: [[{test 1} {\_id ObjectID("633a870add68ad26c4a54d2f")}]], ordered: true }"

Is there anyone who succeed with insert data in node-red via mongoDB Atlas?  
I hope you guys help me.  
Regards.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/7/a72787dc198a5bf67d2e8d4e81b01ef404c35592.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 December 2022 07:10 UTC](https://discourse.nodered.org/t/how-to-insert-data-via-mongodb-atlas/68503/2 "2022-12-02T07:10:54Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
