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
- 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. ...