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>');
```
ReplaceCan you provide the code?
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.....
Recommended threads
- Function connected custom domain error: ...
My domain is served through Cloudflare. Domain is now connected with the appwrite function. But when accessing the domain, I get the below error. Any suggestion...
- Error | general_unknown
I have built a website using Appwrite Cloud as backend, and also using sites for deployment. My website is live but sometimes it shows Appwrite's Error general_...
- Introducing new string column types made...
Adding new string types is hugely bennificial! Unfortunately it made the current column types not editable to change their types to the new longer field types.