# Using insert function for collection

**URL:** <https://forum.wixstudio.com/t/using-insert-function-for-collection/42243>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [August 11, 2020, 11:08am UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243 "2020-08-11T11:08:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ar1](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ar1/32/10170_2.png) [@ar1](https://forum.wixstudio.com/u/ar1)\
**Post date:** [August 11, 2020, 11:08am UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243/1 "2020-08-11T11:08:11Z")

</div>

Hi,

I’m trying to use the insert code to commit content to a database collection that I have created.

When I try running the code, I get this error in the developer console - WDE0025: The myCollection collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor

I have tried multiple iterations of the collection name. Any help is greatly appreciated!

```javascript
export function submit_click(event) {
 let A1 = $w('#DD8').value;
 let A2 = $w('#DD2').value;
 let A3 = $w('#DD1').value;
 let A4 = $w('#R1').value;
 let A5 = $w('#R2').value;
 let A6 = $w('#R3').value;
 let A7 = $w('#R4').value;
 let A8 = $w('#R5').value;
 let A9 = $w('#R6').value;
 let A10 = $w('#R7').value;
 let A11 = $w('#R8').value;
 let A12 = $w('#R9').value;
 let A13 = $w('#R10').value;

let toInsert = {

"a1": A1
"a2": A2,
"a3": A3,
"a4": A4,
"a5": A5,
"a6": A6,
"a7": A7,
"a8": A8,
"a9": A9,
"a10": A10,
"a11": A11,
"a12": A12,
"a13": A13
}

wixData.insert("myCollection", toInsert)

.then( (results) => {
 let item = results; //see item below
  } )
  .catch( (err) => {
 let errorMsg = err;
  } )

//if($w('#email').valid)
//$w('#viewresults').show(); 

```

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [August 11, 2020, 11:31am UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243/2 "2020-08-11T11:31:38Z")

</div>

Hello AR,

of course this will not work ^^

You have first to RENAME the variable —\> “myCollection”  
How is called your Database-Collection?

```javascript
export function submit_click(event) {
 let A1 = $w('#DD8').value;
 let A2 = $w('#DD2').value;
 let A3 = $w('#DD1').value;
 let A4 = $w('#R1').value;
 let A5 = $w('#R2').value;
 let A6 = $w('#R3').value;
 let A7 = $w('#R4').value;
 let A8 = $w('#R5').value;
 let A9 = $w('#R6').value;
 let A10 = $w('#R7').value;
 let A11 = $w('#R8').value;
 let A12 = $w('#R9').value;
 let A13 = $w('#R10').value;

 let toInsert = {
 "a1": A1,
 "a2": A2,
 "a3": A3,
 "a4": A4,
 "a5": A5,
 "a6": A6,
 "a7": A7,
 "a8": A8,
 "a9": A9,
 "a10": A10,
 "a11": A11,
 "a12": A12,
 "a13": A13
    }

    wixData.insert("myCollection", toInsert) //<<<------- here is the important line (change the name of the variable to your own DATABASE-NAME)

    .then( (results) => {
 let item = results;
    } )
    .catch( (err) => {
 let errorMsg = err;
    })
}

```

---

<div class="post-metadata">

**Author:** ![ar1](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ar1/32/10170_2.png) [@ar1](https://forum.wixstudio.com/u/ar1)\
**Post date:** [August 11, 2020, 12:46pm UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243/3 "2020-08-11T12:46:28Z")

</div>

Hi Russian-dima,

I’ve tried renaming it to the actual name (see below).

I’ve tried QuizData and dataset6. Neither of these work ☹

![](https://us1.discourse-cdn.com/wix/original/3X/c/f/cf125c57df838381e27c45488a630295e8528e5c.png)

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [August 11, 2020, 12:49pm UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243/4 "2020-08-11T12:49:16Z")

</div>

NOT —\> DATASET ! 🤣  
You have to put in the name of your DATABASE! (Collection).

You are mixing DATASET with DATABASE!

---

<div class="post-metadata">

**Author:** ![ar1](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ar1/32/10170_2.png) [@ar1](https://forum.wixstudio.com/u/ar1)\
**Post date:** [August 11, 2020, 12:56pm UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243/5 "2020-08-11T12:56:23Z")

</div>

@russian-dima Do i put in “QuizData”?

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [August 11, 2020, 7:39pm UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243/6 "2020-08-11T19:39:47Z")

</div>

@ar1

Hello again.

Do the following…

1. activate the “Dev-Mode” (developer-mode) in your Wix-Editor.
2. On the left side you will see a menu, which shows you all the content of your site-project.
3. Scroll-down to the very bottom. There you will find your DATABASES (Data-Collections)
4. Now choose the right DATABASE/COLLECTION and look how it is called?

HOW IT IS CALLED? ----\> Then you put exactly this name of your choosen DATABASE into your CODE.

This is the name you are searching for!😁

```javascript
wixData.insert("INPUT-DATABASE-NAME-HERE", toInsert)

```

something like this…

```javascript
wixData.insert("Quiz", toInsert)

```

If the name of your DATABASE is —\> Quiz

---

<div class="post-metadata">

**Author:** ![ar1](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ar1/32/10170_2.png) [@ar1](https://forum.wixstudio.com/u/ar1)\
**Post date:** [August 12, 2020, 2:08am UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243/7 "2020-08-12T02:08:08Z")

</div>

@russian-dima Thank you, this worked!!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [August 12, 2020, 8:54am UTC](https://forum.wixstudio.com/t/using-insert-function-for-collection/42243/8 "2020-08-12T08:54:38Z")

</div>

@ar1  
You are welcome.  
And do not forget to like it, if you really liked it 😉
