TypeScript
if (keyword) {
setLoading(true);
databases
.listDocuments(
import.meta.env.VITE_PUBLIC_DATABASE_ID,
import.meta.env.VITE_PUBLIC_COLLECTION_ID,
[
Query.search("title", keyword),
Query.orderDesc("$createdAt"),
]
)
.then((response) => {
setCrafts(response.documents);
console.log(response.documents);
})
.catch((error) => {
console.error("Failed to fetch user crafts:", error);
});
setLoading(false);
}
}, [keyword]);```
I have 2 different attributes title, description
so how i can query both at the same time
TL;DR
It seems that the user wants to query two attributes at the same time. Currently, this is not supported. However, a possible workaround is to create a new attribute that combines the text from both attributes and use that in the query. Here is an example of how you can modify your code to include the new attribute:
```useEffect(() => {
if (keyword) {
setLoading(true);
databases
.listDocuments(
import.meta.env.VITE_PUBLIC_DATABASE_ID,
import.meta.env.VITE_PUBLIC_COLLECTION_ID,
[
Query.search("newAttribute", keyword),
Query.orderDesc("$createdAt"),
]
It sounds like you want to have a logical OR which isn't supported at the moment. Make sure to 👍 this issue: https://github.com/appwrite/appwrite/issues/2740
I would recommend creating an attribute containing all the text you want to search across and then use that in your query
Recommended threads
- TablesDB `updateRows` returns `database_...
Hi Appwrite team! I’m seeing a strange issue with TablesDB bulk row updates on a self-hosted Appwrite instance. **Environment** - Appwrite self-hosted `1.9.0` ...
- [SOLVED] Realtime Missing Channels
```js useEffect(() => { let subscription: RealtimeSubscription; async function loadChips() { try { const {rows: chi...
- Update row sheet not loading
After right clicking a row header and click update, the sidebar fails to load (never-ending skeleton)