# Dao.find\_all returns null or empty collection if no rows found?

**URL:** <https://discuss.konghq.com/t/dao-find-all-returns-null-or-empty-collection-if-no-rows-found/2948>\
**Category:** Questions\
**Created:** [March 6, 2019, 9:55am UTC](https://discuss.konghq.com/t/dao-find-all-returns-null-or-empty-collection-if-no-rows-found/2948 "2019-03-06T09:55:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ovazhnev](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/ovazhnev/32/795_2.png) [@ovazhnev](https://discuss.konghq.com/u/ovazhnev)\
**Post date:** [March 6, 2019, 9:55am UTC](https://discuss.konghq.com/t/dao-find-all-returns-null-or-empty-collection-if-no-rows-found/2948/1 "2019-03-06T09:55:55Z")

</div>

In this line

> <https://github.com/Kong/kong/blob/0.14.1/kong/plugins/key-auth/handler.lua#L23>

Shouldn’t we write  
if not creds[1] then  
instead of  
if not creds then  
?

I’m developing very similar plugin and noticed then I have to add “[1]” to make things work. I’ve tried to print returned value and this is something like “table…”, but if I add [1] then it’s null. So looks like “find\_all” always returns non-null value. Just like in java: for collections if no entries are found you will return empty collection, not null.

I’ve checked master but this example is completely reworked there.

---

<div class="post-metadata">

**Author:** ![ovazhnev](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/ovazhnev/32/795_2.png) [@ovazhnev](https://discuss.konghq.com/u/ovazhnev)\
**Post date:** [March 6, 2019, 10:03am UTC](https://discuss.konghq.com/t/dao-find-all-returns-null-or-empty-collection-if-no-rows-found/2948/2 "2019-03-06T10:03:36Z")

</div>

Never mind, understood intention of this line right after asking the question 🙂 Looks like it covers the case when information can not be loaded (no db access or something like this).  
Wanted to delete this post but have no permission.
