Skip to content
Back

User Queries not working

  • 0
  • Auth
  • Cloud
Danny
20 Jun, 2025, 20:29

When I try to use queries on users, it gives error saying invalid query method.

Now, I dont know whether it is possible or not to query users or it’s just some bad code from my side.

Any help will be appreciated.

TL;DR
Issue: Developer facing an error with the queries on users in the Node.js SDK for Appwrite, getting an "invalid query method" error. Solution: The `list` method for users in Appwrite's Node.js SDK doesn't directly support queries. Instead, you can use the `createSearch` method to create a complex search query. Here's an updated code snippet: ```js const search = new sdk.Search(client) const queries = [sdk.Search.field('name', 'User Name')]; // Define your custom queries here const result = await search.create('<COLLECTION_ID>', queries, '<SEARCH>'); ``` Replace
Axistro
20 Jun, 2025, 20:44

Can you provide the code?

Axistro
20 Jun, 2025, 20:47
TypeScript
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setKey('<YOUR_API_KEY>'); // Your secret API key

const users = new sdk.Users(client);

const result = await users.list(
    [], // queries (optional)
    '<SEARCH>' // search (optional)
);
``` If its like this then this should work.....
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