Hi everyone, I can’t solve this problem, or at least in part:
I already read these discussions:
I started a query to a collection. This gave me many duplicate results.
I need to show the results obtained without duplicates on another table.
I wrote this code inspired by the articles already posted, which works for a single column of the destination table where I have to show the results:
function ListaSingoliEventoUtente () {
return wixData.query("DataSetEventoLog")
.eq('DB_LogEventoUtenteConnect', idUtente)
.include("DB_LogEventoConnect")
.descending("DB_EventoData")
.find()
.then(results => {
const ListaEventoSingolo = OttieniEventoSingolo(results.items);
$w("#TableEvento").rows = OpzioniEvento(ListaEventoSingolo);
return
});
}
//-----------------------------------------------------------------------------------------------
function OttieniEventoSingolo(items) {
const EventoSingolo = items.map(item => item.DB_LogEventoConnect.DB_EventoNome);
return [...new Set(EventoSingolo)];
}
//-------------------------------------------------------------------------------------------------------
function OpzioniEvento(uniqueList) {
return uniqueList.map(curr => {
return {"DB_LogEventoConnect.DB_EventoNome":curr};
});
}
So this code shows me a list without duplicates in the “DB_EventoNome” column
Now I would like from this query to be able to see also two other columns of the table compiled without duplicates and corresponding to the query made.
So I tried to write this code, but I get incorrect or empty data:
function ListaSingoliEventoUtente () {
return wixData.query("DataSetEventoLog")
.eq('DB_LogEventoUtenteConnect', idUtente)
.include("DB_LogEventoConnect")
.descending("DB_EventoData")
.find()
.then(results => {
const ListaEventoSingolo = OttieniEventoSingolo(results.items);
$w("#TableEvento").rows = OpzioniEvento(ListaEventoSingolo);
return
});
}
//-------------------------------------------------------------------------------------------------------
function OttieniEventoSingolo(items) {
const EventoData = items.map(item => item.DB_LogEventoConnect.DB_EventoData);
const EventoNome = items.map(item => item.DB_LogEventoConnect.DB_EventoNome);
const EventoTipo = items.map(item => item.DB_LogEventoConnect.DB_EventoTipo);
const EventoSingolo = {EventoData,EventoTipo,EventoNome};
return [...new Set(EventoSingolo)];
}
//-------------------------------------------------------------------------------------------------------
function OpzioniEvento(uniqueList) {
return uniqueList.map(curr => {
return {"DB_LogEventoConnect.DB_EventoData":curr,
"DB_LogEventoConnect.DB_EventoNome":curr,
"DB_LogEventoConnect.DB_EventoTipo":curr};
});
}
I can’t understand where I’m wrong. Someone has some ideas and can help me
Thank you