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
- How can I disable client-side account re...
Hi everyone! I’m currently building a game backend using Appwrite, and I’d like to prevent users from creating new accounts directly through the client. My go...
- relationships bug or error idk
hey every one, am using am using appwrite on a project and ran into a problem where by created a relationship and two way to be specific and it is stuck on proc...
- Domain is owned by a different organizat...
Hi Appwrite team, I'm trying to add my custom domain **futlive9.com** to my project, but I'm getting the error: "Domain is owned by a different organization." ...