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
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...
- Streamlit UI and local DB
I want to use Appwrite for automation, like run watchdog service every morning 3 am. Anyone got suggestions, already explored github and documentation no luck. ...