Back

Database query

  • 0
  • Databases
  • Flutter
saswatsaubhagya
18 Feb, 2023, 11:22

i am using flutter sdk (appwrite: ^8.2.2) and cloud appwrite. When i am try to query getting an error -: Index not found: user_id

user_id is the attribute in my db.

My code is below

await databases.listDocuments( databaseId: AppWriteConstants.databaseId, collectionId: AppWriteConstants.colProjectUserRole, queries: [ Query.equal('user_id', prefs.getString(PreferenceType.userId) ?? ''), ], )

TL;DR
The user is facing an issue with a database query using Flutter SDK and Appwrite. They are getting an error "Index not found: user_id" when trying to query. The solution to this issue is to create an index for the 'user_id' attribute. The user can refer to the Appwrite documentation on indexes for more information.
Ponguta_
18 Feb, 2023, 15:28

You must create an index of your attribute in order to use it in a query.

Ref: https://appwrite.io/docs/databases#indexes Also see this post by VicentGe https://dev.to/appwrite/how-do-i-index-my-appwrite-collection-2o4n

saswatsaubhagya
18 Feb, 2023, 15:51

Thank you @Ponguta_ . It solve the issue.

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