# Access to the DB

**URL:** <https://forum.wixstudio.com/t/access-to-the-db/10122>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [January 11, 2022, 1:46pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122 "2022-01-11T13:46:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![claudio-d-ambrosio](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/claudio-d-ambrosio/32/876_2.png) [@claudio-d-ambrosio](https://forum.wixstudio.com/u/claudio-d-ambrosio)\
**Post date:** [January 11, 2022, 1:46pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/1 "2022-01-11T13:46:06Z")

</div>

Why are there days, like today, that accessing the DB from javascript doesn’t work on my site? I have several functions that access the Collections, take data to put on the button labels on the page. This operation doesn’t work today, why? I have not made any changes to the site.

Thanks  
Claudio

---

<div class="post-metadata">

**Author:** ![giri-zano](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/giri-zano/32/80469_2.png) [@giri-zano](https://forum.wixstudio.com/u/giri-zano)\
**Post date:** [January 11, 2022, 2:57pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/2 "2022-01-11T14:57:40Z")

</div>

I had something similar 2 days ago. Turned out the a query (which has been working fine for months) suddenly no longer returned a result. Have a look at the return value from the (empty) query. The parameters are repeated at the end. Have a close look to see if that’s your problem.

---

<div class="post-metadata">

**Author:** ![claudio-d-ambrosio](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/claudio-d-ambrosio/32/876_2.png) [@claudio-d-ambrosio](https://forum.wixstudio.com/u/claudio-d-ambrosio)\
**Post date:** [January 12, 2022, 1:14pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/3 "2022-01-12T13:14:37Z")

</div>

Thanks, yes, the effect is this, the queries don’t return anything (empty). but why does it happen? Today, for example, it’s ok.

---

<div class="post-metadata">

**Author:** ![giri-zano](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/giri-zano/32/80469_2.png) [@giri-zano](https://forum.wixstudio.com/u/giri-zano)\
**Post date:** [January 12, 2022, 6:13pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/4 "2022-01-12T18:13:57Z")

</div>

@claudio-d-ambrosio Without any code I could not possibly tell. Maybe Wix even did another commit on wix-data, to fix some bug, I really do not know. So I would keep checking it for the next couple of days and if it returns, show code here, maybe we see something.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [January 12, 2022, 6:20pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/5 "2022-01-12T18:20:08Z")

</div>

And important… If you encounter issues like this or other anomalies, keep in mind this forum is not a support site, and **is not monitored for bugs or system issues**. Please report bugs to [Wix Customer Care](https://support.wix.com/en/article/contacting-wix-customer-care-for-support) to ensure timely handling of your problem. They track and monitor all incoming issues and will escalate bugs to product teams.

---

<div class="post-metadata">

**Author:** ![empro2pro](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/empro2pro/32/31056_2.png) [@empro2pro](https://forum.wixstudio.com/u/empro2pro)\
**Post date:** [January 13, 2022, 10:17am UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/6 "2022-01-13T10:17:23Z")

</div>

Lads did you find a reason to that behaviour or a solution? Looks like I have similar problem.

---

<div class="post-metadata">

**Author:** ![claudio-d-ambrosio](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/claudio-d-ambrosio/32/876_2.png) [@claudio-d-ambrosio](https://forum.wixstudio.com/u/claudio-d-ambrosio)\
**Post date:** [January 13, 2022, 5:23pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/7 "2022-01-13T17:23:28Z")

</div>

ok thanks

---

<div class="post-metadata">

**Author:** ![claudio-d-ambrosio](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/claudio-d-ambrosio/32/876_2.png) [@claudio-d-ambrosio](https://forum.wixstudio.com/u/claudio-d-ambrosio)\
**Post date:** [January 13, 2022, 5:40pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/8 "2022-01-13T17:40:18Z")

</div>

@giri-zano

Of these functions (access to the db, small calculation, and writing on the label button) I have many because I have many buttons placed on the page.  
Could that be the problem?

Here is the example code I use  
Thanks

```javascript
    // query 1
    let queryGSC = wixData.query('CLASSEVEN_OK').eq('squadra', $w(hFuori1).label);
    queryGSC.find().then((resultsGSC) => 
    {
        let gginC = resultsGSC.items[0]['ggout'];
        let seC = resultsGSC.items[0]['segnaf'];

        // query 2
        let queryGSCF = wixData.query('CLASSEVEN_OK').eq('squadra', $w(hCasa1).label);
        queryGSCF.find().then((resultsGSF) => 
        {
            let ggoutF = resultsGSF.items[0]['ggin'];
            let suF = resultsGSF.items[0]['subitic'];

            // small calculation
            let percSegnaC = Math.round((Math.round((seC/gginC)*100) + Math.round((suF/ggoutF)*100))/2);
            
            // write on label button that displays nothing (sometimes).
            $w(gsFuori).label = String(percSegnaC);  
            
            if (parseInt($w(gsFuori).label, 10) >= 75)
            {
                $w(gsFuori).disable();
            }                        
        })
    })

```

---

<div class="post-metadata">

**Author:** ![giri-zano](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/giri-zano/32/80469_2.png) [@giri-zano](https://forum.wixstudio.com/u/giri-zano)\
**Post date:** [January 14, 2022, 2:57pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/9 "2022-01-14T14:57:25Z")

</div>

@claudio-d-ambrosio Don’t see anything wrong with the code, except that you assume too much. E.g. if a query, for whatever reason, returns nothing, you still continue to work with the first (not available entry), which will not work.  
So first, after each query, test like so:

```javascript
if(resultsGSC.items.length >0){
	//rest of existing code here
}
else {
	console.log ("No rows found");
}

```

Then look at your logs when it doesn’t do what you expected.

---

<div class="post-metadata">

**Author:** ![claudio-d-ambrosio](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/claudio-d-ambrosio/32/876_2.png) [@claudio-d-ambrosio](https://forum.wixstudio.com/u/claudio-d-ambrosio)\
**Post date:** [January 18, 2022, 2:37pm UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/10 "2022-01-18T14:37:13Z")

</div>

I tried to contact Customer care but I can’t find the right topic in the list.  
Today, for example, the refresh() function of the tables don’t work and I wanted to report it but I don’t know how to do it.

---

<div class="post-metadata">

**Author:** ![claudio-d-ambrosio](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/claudio-d-ambrosio/32/876_2.png) [@claudio-d-ambrosio](https://forum.wixstudio.com/u/claudio-d-ambrosio)\
**Post date:** [March 3, 2022, 10:40am UTC](https://forum.wixstudio.com/t/access-to-the-db/10122/11 "2022-03-03T10:40:16Z")

</div>

Hi, the problem is still there, I have contacted support @yisrael-wix but they have not solved the problem.  
If I select a row on my table, and then call a **refresh()** function, the row stays selected. Why ??
