Hello,
I’m looking for someone to help me.
For some time to understand how to delete from a dataset with a reference field all the references of this table referring to an id of the source table.
I’ll explain:
I have this table called “DataSetEventoLightroom” where there is a reference field to a main table
I would like to be able to delete all the items that refer to the same reference of the main folder:
this is what I tried to do. I used removeReference because remove can not remove more than one item at a time.
I know the id of the main table so I find the object all the items in the table referenced by the reference id
function countRowLightTable() {
wixData.query("DataSetEventoLightroom")
.eq('DB_EventoCodice', idEvento)
.find()
.then( (results) => {
itemsLightTrovate = results.items;
});
}
Now I try to use removeReference to delete all references from the table
export function button17_click(event) {
wixData.removeReference('DataSetEventoLightroom', 'DB_EventoCodice', 'idEvento', 'itemsLightTrovate')
.then(() => {
console.log('Erase item');
});
}
where is it:
-
DataSetEventoLightroom - is the name of the table with references
-
DB_EventoCodice - is the column where the reference to the main table is saved
-
idEvent - is the id of the main table saved in the reference column
-
itemsLightTrovate - are all the items found by the query in the table with the same reference
I hope I have been clear and that someone can help me.
Thank you all