I’m using a simple code to create new informations in my database.
Code :
let toSave = {
"wishlistItem": product_name,
"proprietaire": userId
};
The cell “wishlistItem” type is reference. Each time that I use the function, it said “Reference is broken” so I can’t show my items in a table. I already check, my collumn in my second database where I refered is “product_name”. Thank you for your help!
Hi Simon,
Can you please share a link to your site so we can inspect ?
Roi
Sure.
Link where the information is added : Sources EEIL
You have to click on the star to add it.
Hi Simon,
In your collection “wishlistItem” is a reference field (type Object). product_name variable is Type number. that is way the reference is broken. Lets fix that!
product_name should be equal to the id of the item in the collection.
It should look like this:
product_name = {ref: '945eaf01-9f61-41e1-8be6-31ddd345e8f9'} // the ref refers to _id fieldkey in source collection.
Just fetch the correct id field.
My suggection:
wixData.query('yourCollection')
.eq('numero',numberOfProduct)
.find()
.then((results) => {
product_name = {ref: `${results.items[0]._id}`}
})
Good luck!
Roi