const fetchReviews = useCallback(async (placeId) => {
const cleanPlaceId = placeId.replace(/[^a-zA-Z0-9_.-]/g, '').replace(/^[^a-zA-Z]/, '');
const truncatedPlaceId = cleanPlaceId.substring(0, 34);
const truncatedPlaceId1 =
a${truncatedPlaceId}`;
try {
const response = await databases.listDocuments(
process.env.REACT_APP_DATABASE_ID,
process.env.REACT_APP_COLLECTION_ID,
Query.equal('coordinates',[truncatedPlaceId1])
);
const fetchedReviews = response.documents.map((document) => document.review);
setReviews((prevReviews) => ({
...prevReviews,
[placeId]: fetchedReviews,
}));
} catch (error) {
console.error('Error fetching reviews:', error);
}
}, []); ` I don't know what's causing the error below
Error fetching reviews: AppwriteException: Invalid queries: Value must a valid array and Value must be a valid string and no longer than 4096 chars at Client.<anonymous>
Try
const response = await databases.listDocuments(
process.env.REACT_APP_DATABASE_ID,
process.env.REACT_APP_COLLECTION_ID,
[
Query.equal('coordinates',[truncatedPlaceId1])
]
);
yes thanks error went away
hey could you clarify this error this is the new error
Error fetching reviews: AppwriteException: Index not found: coordinates at Client.<anonymous>
Thinks you use cloud
You need to create index for equal queries
You can create index directly via console (website)
okay thanks Bouahaza for your so much fast and correct help
Use Query by Appwrite correct method
FYI, it's best to use 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.
and FYI, the queries are documented here: https://appwrite.io/docs/databases-queries
[SOLVED]Use Query by Appwrite correct method
okay thanks Steven I will remember this 😊😊
[SOLVED] Use Query by Appwrite correct method
Recommended threads
- self-hosted auth: /v1/account 404 on saf...
Project created in React/Next.js, Appwrite version 1.6.0. Authentication works in all browsers except Safari (ios), where an attempt to connect to {endpoint}/v1...
- delete document problems
i don't know what's going on but i get an attribute "tournamentid" not found in the collection when i try to delet the document... but this is just the document...
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...