top of page

Forum Posts

Daniel Talero
Jun 01, 2023
In Velo Pro Discussion
Hey guys. I have two big datasets (more than 80.000 items). Im trying to perfome some queries and it works when the dataset is like 20.000 items but it crashes when its bigger. The message in the java console says: Uncaught (in promise) Error: WDE0028: Operation time limit exceeded. Here is part of the code: import wixData from 'wix-data'; $w("#table1").columns = [ { "id": "Diagnóstico", "dataPath": "Diagnóstico", "label": "Diagnóstico", "type": "string" }, { "id": "Porcentaje", "dataPath": "Porcentaje", "label": "Porcentaje", "type": "string" } ]; // Establecer la estructura de columnas en la tabla const columns = [ { "id": "Ciudad", "dataPath": "Diagnóstico", "label": "Ciudad", "type": "string" }, { "id": "Porcentaje", "dataPath": "Porcentaje", "label": "Porcentaje", "type": "string" } ]; $w("#tablaCiudad").columns = columns; const columnsProfesion = [ { "id": "Profesion", "dataPath": "Diagnóstico", "label": "Profesión", "type": "string" }, { "id": "Porcentaje", "dataPath": "Porcentaje", "label": "Porcentaje", "type": "string" } ]; $w("#profesionTable").columns = columnsProfesion; // Establecer la estructura de columnas en la tabla const columnsEncuesta = [ { "id": "Item", "dataPath": "Item", "label": "Item", "type": "string" }, { "id": "Porcentaje", "dataPath": "Porcentaje", "label": "Porcentaje", "type": "string" } ]; $w('#encuestaTable').columns = columnsEncuesta; async function countRecords() { let startDate = $w('#datePicker1').value; let endDate = $w('#datePicker2').value; let yearValue = startDate.getFullYear(); let monthValue = startDate.getMonth(); let dayValue = startDate.getDate(); let startDateSrch = new Date(yearValue, monthValue, dayValue, 0, 0, 0); yearValue = endDate.getFullYear(); monthValue = endDate.getMonth(); dayValue = endDate.getDate(); let endDateSrch = new Date(yearValue, monthValue, dayValue, 23, 59, 59); const MAX_ITEMS_PER_QUERY = 1000; async function fetchAllRecords(query) { let records = []; let skip = 0; let hasMoreRecords = true; while (hasMoreRecords) { let response = await query .limit(MAX_ITEMS_PER_QUERY) .skip(skip) .find(); records = records.concat(response.items); if (response.items.length < MAX_ITEMS_PER_QUERY) { hasMoreRecords = false; } else { skip += MAX_ITEMS_PER_QUERY; } } return records; } let hcCollection = await fetchAllRecords( wixData.query("BACKUPHC") .between("fechaConsulta", startDateSrch, endDateSrch) .eq("atendido", "ATENDIDO") .hasSome("codEmpresa", "PARTICULAR") ); let numeroIds = hcCollection.map(item => item.numeroId); let uniqueNumeroIds = [...new Set(numeroIds)]; console.log("LOS QUE SON", uniqueNumeroIds); // GÉNERO $w('#generoBtn').onClick(async (event) => { console.log("si"); let formCollection = await fetchAllRecords( wixData.query("FORMULARIOBK").hasSome("documentoIdentidad", uniqueNumeroIds) ); let matchingForms = formCollection.filter(form => uniqueNumeroIds.includes(form.documentoIdentidad)); let generosCoincidentes = matchingForms.map(form => `${form.documentoIdentidad} - ${form._createdDate.toLocaleDateString()}`); let formMaleCount = formCollection.filter(form => form.genero === "MASCULINO").length; let formFemaleCount = formCollection.filter(form => form.genero === "FEMENINO").length; let numFormRecords = formCollection.length; $w("#numFormRecords").text = numFormRecords.toString(); let numHCRecords = hcCollection.length; $w("#numHCRecords").text = numHCRecords.toString(); let numMaleRecords = formMaleCount; $w("#numMaleRecords").text = numMaleRecords.toString(); let numFemaleRecords = formFemaleCount; $w("#numFemaleRecords").text = numFemaleRecords.toString(); let numMatchingRecords = matchingForms.length; $w("#numMatchingRecords").text = numMatchingRecords.toString(); let malePercentage = (numMaleRecords / numMatchingRecords) * 100; $w("#porcentajeMasculino").text = malePercentage.toFixed(2).toString() + "%"; let femalePercentage = (numFemaleRecords / numMatchingRecords) * 100; $w("#porcentajeFemenino").text = femalePercentage.toFixed(2).toString() + "%"; }); Help!
0
3
24
Daniel Talero
Apr 23, 2021
In Coding with Velo
Hi guys: I have an aggregation for my database but i need to group by date interval. This is the code: export function datePicker2_change_1(event) { function pad(num, size) { var s = num+""; while (s.length < size) s = "0" + s; return s; } const pickerDay = $w('#datePicker1').value.getDate().toLocaleString(); const pickerMonth = $w('#datePicker1').value.getMonth()+1; const pickerYear = $w('#datePicker1').value.getFullYear().toString(); const pickerDateMin = new Date(pickerYear+"-"+pad(pickerMonth,2)+"-"+pad(pickerDay,2)+"T00:00:00.000Z"); const pickerDay2 = $w('#datePicker2').value.getDate().toLocaleString(); const pickerMonth2 = $w('#datePicker2').value.getMonth()+1; const pickerYear2 = $w('#datePicker2').value.getFullYear().toString(); const pickerDateMax = new Date(pickerYear2+"-"+pad(pickerMonth2,2)+"-"+pad(pickerDay2,2)+"T23:59:59.999Z"); console.log(pickerDateMin, "end date"); console.log(pickerDateMax, "end date"); const filter = wixData.filter().contains("codEmpresa", codEmpresa) const dates = wixData.filter().gt("fechaConsulta", pickerDateMin).lt("fechaConsulta", pickerDateMax); wixData.aggregate("HistoriaClinica") .having(dates) .filter(filter) .group("ciudad") .count() .run() .then( (results) => { let items = results.items; $w("#table1").rows = items; console.log(items) }) } But it doesnt work. Any suggestions?
0
0
39
Daniel Talero
Apr 03, 2021
In Coding with Velo
Hi guys! I have this database: I need to display in a table: - One column grouping the values of Ciudad - Second column showing the count of each Ciudad (city) - Third column counting each label for each city Thanks!
HELP MULTIPLE AGGREGATIONS IN TABLE content media
0
0
8
Daniel Talero
Mar 25, 2021
In Coding with Velo
Hi guys: I have this database I need to display in a table: - One column grouping the values of Ciudad - Second column showing the count of each Ciudad (city) - Third column counting each label for each city Thanks!
Display multiple aggregations in table
 content media
0
0
20
Daniel Talero
Mar 23, 2021
In Coding with Velo
Hey guys: I create an aggregation from a database and I want to show results in a table. This is de code: export function button15_click(event) { wixData.aggregate("HistoriaClinica") .group("ciudad") .count() .run() .then( (results) => { let items = results.items; $w("#table1").rows = items; console.log(items) $w("#table1").columns = [ { "id": "col1", "dataPath": "ciudad", "label": "Ciudad", "type": "string", }, ]; }); } And this is the result in the table: Question is: ¿How can I show the count results in the second column? Thanks!!
Aggregate results in table content media
0
0
190
Daniel Talero
Mar 22, 2021
In Coding with Velo
Guys I have a problem: I need to show the count results from an Aggregate code into a repeater. In the console it works fine but when I try to show the results in a repeater I have this 2 messages: Wix code SDK Warning: The text parameter of "ciudad" that is passed to the text method cannot be set to null or undefined. Wix code SDK error: Each item in the items array must have a member named `_id` which contains a unique value identifying the item. This is the code Im using: export function button15_click(event) { $w('#repeater2').forEachItem (($item, itemData) => { $item("#ciudad").text = itemData.ciudad; }) wixData.aggregate("HistoriaClinica") .group("ciudad") .count() .run() .then( (results) => { let items = results.items; $w("#repeater2").data = results.items; console.log(items) } ); } Any thoughts? Thanks!
0
13
226
Daniel Talero
Mar 11, 2021
In Coding with Velo
Hi guys: How can I see the owner Id Nickname of the field? In the Owner ID field it shows: cb64693d-aa2a-40c7-beb5-acdea517e9da thanks!
0
1
55
Daniel Talero
Feb 02, 2021
In Coding with Velo
Guys I have a problem. Im using SetFieldValue in my code two months ago, but today sometimes it works and some times doesnt. This is the code export function crear_click(event) { $w("#dataset1").setFieldValue("atendido", "PENDIENTE"); $w("#dataset1").save() } Any ideas?
0
16
160
Daniel Talero
Jan 30, 2021
In Coding with Velo
Hi guys: I have a button that set field value to localDateString. But when I open the database it doesnt recognize it as date but as string so if I want to run a query from date, doesnt work. This is the code and the picture of the database. THANKS! const today = new Date(); export function button_click(event) { const options = { weekday: "short", day: "numeric", month: "short", year: 0 }; $w("#dataset1").setFieldValue("fechaConsulta", today.toLocaleDateString('es-CO', options)); $w("#dataset1").save(); THE CODE WORKS FINE BUT... HELP!
String to Date content media
0
2
366
Daniel Talero
Dec 16, 2020
In Coding with Velo
Guys I have a problem: I have a Database that has been filter by user Badge. Aditionally I have a search engine to search by LastName in the same database, but if the user Badge filter is active the search engine doesnt work. This is the code import wixData from 'wix-data'; import wixUsers from 'wix-users'; //////FILTER BY BADGE/////// $w.onReady(function () { check();}); wixUsers.onLogin( (user) => {check();} ); function check () { wixData.query("Members/Badges") .hasSome("members", wixUsers.currentUser.id) .find() .then((results) => { let a = results.items[0].title; if (a === 'KPMG') { $w('#tabla').show(); wixData.query("HistoriaClinica") .hasSome("empresa", ["KPMG SAS", "ADVISORY TAX & LEGAL SAS", "ADV.SERV.BOGOTA"]) .find() .then( (results) => { $w("#tabla").rows = results.items; } ); ////SEARCH ENGINE//// let debounceTimer; export function iTitle_keyPress_1(event, $w) { if (debounceTimer) { clearTimeout(debounceTimer); debounceTimer = undefined; } debounceTimer = setTimeout(() => { filter($w('#iTitle').value); }, 200); } let lastFilterTitle; function filter(title) { if (lastFilterTitle !== title) { $w('#dataset1').setFilter(wixData.filter() .contains('numeroId', title) .or(wixData.filter() .contains("primerApellido", title))) lastFilterTitle = title } } Any Ideas?
0
2
74
Daniel Talero
Nov 22, 2020
In Coding with Velo
I have a calculated field and I need to save it into a database. The calculated field is working fine but the save button doesnt The code: //CALCULATED FIELD export function calcularIMC_click_1(event, $w) { let Talla = Number($w("#talla").value); let Peso = Number($w("#peso").value);   $w("#imc").value = (Peso/(Talla*Talla)).toString(); } //SAVE BUTTON export function salvar_click(event){    $w("#dataset1").setFieldValue("mdImc", $w("#imc").value);    } It doesnt work. Can you help me?
0
16
117
Daniel Talero
Oct 12, 2020
In Coding with Velo
Hi guys: I need to import an external database from a twin website. So I create my http-js in the site A and the query works fine if I use the url. You can test it: https://www.medidata-bsl.net/_functions/myFunction The problem is when I try to create the database in the site B. What am doing is: - Go to Database - Add a external collection - Create a namespace - Add an Endpoint URL (https://www.medidata-bsl.net/_functions/myFunction ) But when I clic on Add button I got this error PLEASE HELP ME!
External database content media
0
16
329

Daniel Talero

More actions
bottom of page