Appwrite :: getLikesByUserIdAndPostId :: error AppwriteException: Document with the requested ID co
- 0
- Web
const getLikesByUserIdAndPostId = async( userId: string, postId: string) => { try { console.log("userId ",userId) console.log("postId ",postId) console.log("likesCollection ",likesCollection)
const userDoc = await db.getDocument(palettegramDB, usersCollection, userId);
const postDoc = await db.getDocument(palettegramDB, postsCollection, postId);
if (userDoc && typeof userDoc === 'object') {
console.log("userId ", userDoc);
} else {
console.log("Error fetching user document");
}
console.log("postId ",postDoc)
const query = Query.and([
Query.equal("userId", userDoc.$id),
Query.equal("postId",postDoc.$id)
])
const likes = await db.listDocuments(
palettegramDB,
likesCollection,
[query]
)
return !!likes;
} catch (error) {
console.log("Appwrite :: getLikesByUserIdAndPostId :: error ",error);
}
} but there is data in usersCollections and postsCollection but it throwing error bz userDoc and postDoc value is null
Why did you delete your previous message in https://discord.com/channels/564160730845151244/1242108221972414475
it was not same error
What are the permissions on the collections and is document level security enabled?
all modification, read, create,update,delete
There is usersCollection with user details, postsCollection with post details and likesCollection have user reference with post reference. I am trying to fetch whether user is present in likesColllection with post id. This futher does that only ```const getLikesByUserIdAndPostId = async( userId: string, postId: string) => { try { console.log("userId ",userId) console.log("postId ",postId) console.log("likesCollection ",likesCollection)
const userDoc = await db.getDocument(palettegramDB, usersCollection, userId);
const postDoc = await db.getDocument(palettegramDB, postsCollection, postId);
if (userDoc && typeof userDoc === 'object') {
console.log("userId ", userDoc);
} else {
console.log("Error fetching user document");
}
console.log("postId ",postDoc)
const query = Query.and([
Query.equal("userId", userDoc.$id),
Query.equal("postId",postDoc.$id)
])
const likes = await db.listDocuments(
palettegramDB,
likesCollection,
[query]
)
return !!likes;
} catch (error) {
console.log("Appwrite :: getLikesByUserIdAndPostId :: error ",error);
}
}``` but its showing error. When I tried to console the value its throwing error on userDoc and postDoc.
Please share a screenshot
Please try granting Any
access
its throwing same error for any access as well.
What about the related collections?
I have given any access to all collections likesCollection, postsCollection and userCollections
Screenshots please
of any access?
Yes
Recommended threads
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- Custom emails
What happen if I use a third party email provider to customize my emails and my plan run out of emails/month? Appwrite emails are used as fallback sending emai...