When I use Query.search() instead of returning rows with the keywords provided it just returns all the rows in the table.
TL;DR
Issue: Query.search() function is returning all rows in the table instead of filtering by the provided keywords.
Solution:
Instead of passing the 'content' column directly, use Query.field("content") inside Query.search() to specify the field to search in. Update the code as follows:
```typescript
queries: [Query.search(Query.field("content"), query)],
```
This will correctly filter rows based on the provided keywords.TypeScript
try {
return await tablesDB.listRows<Post>({
databaseId: CRIC_TALK_DATABASE_ID,
tableId: POSTS_TABLES_ID,
queries: [Query.search("content", query)],
});
} catch (error) {
console.log(`Error while searching posts ${error}`);
throw error;
}
}```
this is the code i am using
[SOLVED] Query.search() returning all rows in the table
Recommended threads
- Relations within the same table
Hello, I'm currently building a sort of dictionary (a literal one) and thus I need words (which is one single table of words in my database) to be able to have ...
- 1:1 relationship doesn’t sync after re-a...
Hi, I’m trying to use a two-way one-to-one relationship. It works fine when I create a record with the relationship set, and it also works when I unset it. But ...
- Upsert with setting permissions
Hi there, I am using self-hosted appwrite v1.7.4 and trying to use the bulk update stuff that was released with 1.7.x. Unfortunally I found that there is an ser...