Wix-data insert function doent work

Hi , iam trying to insert the value “AAPL” into collection named “symtest” by the following function :

async function dataInsert() {
 var toInsert = {
 "logo" : "AAPL"
   };
 var response =  await wixData.insert("symtest", toInsert);

 return response;

}

In the console log i see that everything is ok , i got “cretatedDate” , “updaedDate” and id.

But in the collection nothing happened.

-Did you test it in “previe-mode”, or on “live-site”?
-Did you synced your live and preview-database?
-Did you gave all needed permissions?
-Why do you use RETURN? You need it?

Normal way of inserting DATA into collection…


import wixData from 'wix-data';

$w.onReady(async function () {dataInsert()}

function dataInsert() {
 let myCollection = "symtest"
 let toInsert = {"logo" : "AAPL"};

   wixData.insert("myCollection", toInsert)
   .then( (results) => {
     let item = results; 
    console.log(item)
   })
   .catch( (err) => {
     let errorMsg = err;
   });
}

Thx Dima , was issue with the live database, i didnt know that i should switch to live database in order to the data.

That are always the same problems :grin:

  1. Syncing DATABASES
  2. DATABASE-Permissions
  3. READ & WRITE settings of the DATASETs

But i am happy when i could help you.

Good luck and happy coding.

I’m trying to import data into a collection from an Excel spreadsheet. The collection includes two multi-reference fields which the Velo CSV import function will not handle. So I can import everything except those two fields. It has been suggested that I use the insert function to insert the data from those two fields into the corresponding rows in the collection. Does anyone have a s suggestion for code that would use the CSV file from the Excel spreadsheet as the source for the insert data?

Thanks

@russian-dima Thanks. Found that page yesterday. Also, I accidentaly found the actual format for the CSV file for multi-reference fields using then import button on a collection: [“sys id”,“sys id”,“sys id”, . . .] and it works like a charm.