Hi everyone,
Let me start off by saying that Im thoroughly confused.
So I’ve 2 collections - CCDB & IDB
CCDB has the primary key of Champion ID (field key:champId, type:text)
IDB has a primary key DeviceName (field:title, type:text) and a reference field Champion ID (field key: champId, type: reference).
So, n items in the IDB collection belong to 1 item in CCDB collection.
Now, when I’m inserting data into IDB collection using following code below, the database shows a red underline saying : “Cell value type is Number. Change to Reference.”
getitems("pc").then(res => {
let toInsert = {
"title": res[i].champion_id, //reference to CCDB
"description": res[i].Description,
"deviceName": res[i].DeviceName,
"itemId": res[i].ItemId
}
wixData.insert("IDB", toInsert)
.then(results => {
let item = results;
console.log(item);
})
.catch(err => {
let errorMsg = err;
console.log(errorMsg);
});
})
I searched the documentation and found wixData.insertReference()… but im not sure how to use the method in this scenario or even if it is possible to use.
And since the number of Items in IDB would be more than 100, I cant insert reference manually. How can I solve this with code?
Thanks.