Skip to content
Back

Empty listRows() response

  • 0
  • 3
  • Databases
  • React Native
  • Functions
  • REST API
Sherriz
5 Jan, 2026, 03:24

Hi there, I'm shehryar, I'm new to react native and appwrite as well, I'm following a tutorial, what's surprising is the listRows({databaseId, tableId, queries}) is returning an empty response like {rows :[], total :0} but on the other hand when i call getRow({databaseId, tableId, rowId}) it works and I get an expected response. I'm not following what I am doing wrong. i have all permissions checked as well.

🙏 Will appreciate the help.

TL;DR
User's code was returning an empty array due to querying without checking if the user exists. By updating the code to first check for the user's existence before fetching, the issue was resolved. Additionally, there was a discussion about potential security risks and the analogy of searching for Elon Musk on the moon when he doesn't exist.
5 Jan, 2026, 07:16

First of all, can you please tell whether that tutorial is new or old? I mean does it mentions old Collection based schema?

5 Jan, 2026, 07:34

Please check this

5 Jan, 2026, 07:41

it's not collection rather tables I believe.

5 Jan, 2026, 08:34

I've found something in your code which possibly could be a reason behind this

5 Jan, 2026, 08:35

You're querying without even checking that if the user exists or not in the first place

5 Jan, 2026, 08:46

So, try checking for the user first by updating your code like this -

  1. Change no. 1
TypeScript
useEffect(() => {
   fetchHabit();
}, []);
  1. Change no. 2
TypeScript
const fetchHabit = async () => {
  if (!user?.$id) return;

  const response = await databases.listRows({
    databaseId: DATABASE_ID,
    tableId: "habits",
    queries: [Query.equal("createdBy", user.$id)],
  });

  console.log(response);
};
5 Jan, 2026, 09:13

Okay its working but shouldn't it just give an error if the user doesn't exist since I'm using try catch

5 Jan, 2026, 09:39

Thats bad for security. You dont want anyone to know if a certain user exists or not.

5 Jan, 2026, 09:40

Definitely but in a dev environment, shouldn't it be throwing an error

5 Jan, 2026, 09:41

How could appwrite determine if its a dev build or a production. Plus when you are doing query, the db does not know what UserId means. It just says, hey there is no document by this query.

5 Jan, 2026, 09:44

UserId is something I'm creating from the ID module, secondly if it's a security measure from appwrite I suppose I can wrap my head around it.

5 Jan, 2026, 10:00

No I meant like You are querying by an atrribute. It did not throw an error, cause the oparation isself correct. You tried to fetch something, which may or may not exist. Like alone in Moon calling elon musk. Is the calling incorrect? No Is elon musk a wrong thing? No But no one responded cause there is no elon musk on the moon 😅 The process is correct, the placement is wrong

1
5 Jan, 2026, 16:43

Thanks 👍

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more