Appwrite :: getLikesByUserIdAndPostId :: error AppwriteException: Invalid `documentId` param: UID m
- 0
- Web
const getLikesByUserIdAndPostId = async( userId: string, postId: string) => { try { console.log("userId ",userId,"postId ",postId); const query = Query.and([ Query.equal("userId", userId), Query.equal("postId",postId) ]) const likes = await db.getDocument( palettegramDB, likesCollection, query ) return !!likes; } catch (error) { console.log("Appwrite :: getLikesByUserIdAndPostId :: error ",error);
}
}
If you're using queries, you need to use listDocuments() instead. getDocument() can only be used if you are fetching a single document that you have the ID of already
I want to check whether userId with postId is present in the collection or not. Thats why I am using Query.and()
So you want to get a list of documents that have a specific userId and postId?
It will only be a single entry, not multiple
That shouldn't matter, it'll just return the one entry if there is only one. If you are doing anything with queries or you do not already know the ID of the document, you will need to use listDocuments() to fetch the data
after using listDocuments() its giving Argument of type 'string' is not assignable to parameter of type 'string[]'. forquery
Wrap your query variable in an array, like this
const likes = await db.listDocuments(palettegramDB, likesCollection, [query]);
ok
Recommended threads
- Problem with Google Workspace at DNS Rec...
Hello, I bought a domain at Namecheap, and Google Workspace used to work there, but now that I switched from Custom DNS to Appwrite's nameservers, it doesn't w...
- change role of a team member in Appwrite
It's not possible to add/change roles of a team meber in Appwrite Frontend. When you click on a member of a team you get forwarded to the configuration page of ...
- Session not found. Please run appwrite l...
I have encounter an issue with appwrite CLI They asking for a login session but in the doc, itβs mention that only setup client with endpoint / api key is enou...