# Query has stopped working

**URL:** <https://forum.wixstudio.com/t/query-has-stopped-working/40381>\
**Category:** Ask the community\
**Tags:** wix-members-area, question, code\
**Created:** [June 17, 2021, 11:45am UTC](https://forum.wixstudio.com/t/query-has-stopped-working/40381 "2021-06-17T11:45:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cue](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@Cue](https://forum.wixstudio.com/u/Cue)\
**Post date:** [June 17, 2021, 11:45am UTC](https://forum.wixstudio.com/t/query-has-stopped-working/40381/1 "2021-06-17T11:45:20Z")

</div>

For some reason this query doesn’t work, I isolated the AIIMAGES database query and it worked but when added back it did not work( box139 doesn’t not respond) . The AIIMAGES database is a Members generated and updatable database and the dataset .onReady is a Read and Write. Please how do I fix this.

$w ( “#dataset116” ). onReady (() =\> {  
$w ( “#dataset67” ). onReady (() =\> {  
**let** ItemObjai = $w ( “#dataset67” ). getCurrentItem ()  
**if** (( ItemObjai . aiEligibilityStart \< Date . now ())&&( ItemObjai . aiEligbilityEnd \> Date . now ())){  
**let** S = **new** Date ( ItemObjai . aiEligibilityStart )  
**let** E = **new** Date ( ItemObjai . aiEligbilityEnd )

**let** amountofai = wixData . query ( “SEEKERS” )  
. gt ( “\_createdDate” , S )  
**let** aiadded = wixData . query ( “SEEKERS” )  
. isNotEmpty ( “aiImageSearch” )  
**let** ownerr = wixData . query ( “SEEKERS” )  
. eq ( “\_owner” , ItemObjai . \_owner )  
**let** aimages = wixData . query ( “AIIMAGES” )  
. gt ( “\_createdDate” , S )  
**let** mages = wixData . query ( “AIIMAGES” )  
. isNotEmpty ( “image” )  
**let** ownerrr = wixData . query ( “AIIMAGES” )  
. eq ( “\_owner” , ItemObjai . \_owner )  
amountofai . and ( aiadded ). and ( ownerr ). and ( mages ). and ( aimages ). and ( ownerrr )  
. find ()  
. then ( ( results ) =\> {  
**let** numb = results . items . length

**if** ( numb \< ItemObjai . ainumber ){  
$w ( “#box139” ). hide ()  
}  
**else if** ( numb \>= ItemObjai . ainumber ){  
$w ( “#box139” ). show ()

}  
})  
. **catch** (( err ) =\> {  
**let** errorMsg = err ;  
});  
}  
**else** {  
$w ( “#box139” ). show ()  
}  
})  
})

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [June 17, 2021, 6:07pm UTC](https://forum.wixstudio.com/t/query-has-stopped-working/40381/2 "2021-06-17T18:07:30Z")

</div>

It should something like:

```javascript
wixData.query("SEEKERS")
.gt("_createdDate",S)
.isNotEmpty("aiImageSearch")
.eq("_owner",ItemObjai._owner)
.gt("_createdDate",S)
.isNotEmpty("image")
.eq("_owner",ItemObjai._owner) 
.find()

```

---

<div class="post-metadata">

**Author:** ![Cue](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@Cue](https://forum.wixstudio.com/u/Cue)\
**Post date:** [June 17, 2021, 6:46pm UTC](https://forum.wixstudio.com/t/query-has-stopped-working/40381/3 "2021-06-17T18:46:00Z")

</div>

Thanks for the response, but this query is accessing two databases

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [June 17, 2021, 6:53pm UTC](https://forum.wixstudio.com/t/query-has-stopped-working/40381/4 "2021-06-17T18:53:18Z")

</div>

@chidiejike So run two queries (one per each database collection):

```javascript
Promise.all([
query1.find(),
query2.find()
])
.then(res => {
    let allItems = [res[0].items, res[1].items].flat();
    //and continue to work with allItems 
})

```

---

<div class="post-metadata">

**Author:** ![Cue](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@Cue](https://forum.wixstudio.com/u/Cue)\
**Post date:** [June 18, 2021, 10:11am UTC](https://forum.wixstudio.com/t/query-has-stopped-working/40381/5 "2021-06-18T10:11:40Z")

</div>

Thanks JD it works now, but does this bring all the queried items from the databases no matter the amount or does it have a .limit(1000)?

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [June 18, 2021, 12:29pm UTC](https://forum.wixstudio.com/t/query-has-stopped-working/40381/6 "2021-06-18T12:29:03Z")

</div>

@chidiejike it’s up to 1000 per each of them (depends on the .limit() you set).  
If you only need the total number use .count() instead .find().

```javascript
Promise.all([
query1.count(),
query2.count()
])
.then(res => {
    let total = res[0] + res[1];
    //and continue working with total 
})

```

if you need both the first 2,000 items + the total in collection:

```javascript
Promise.all([
query1.limit(1000).find(),
query2.limit(1000).find()
])
.then(res => {
    let first2kItems = [res[0].items, res[1].items].flat();
let total = res[0].totalCount + res[1].totalCount
    //and continue with first2kItems and total
})

```
