fetchPosts
Retrieves paginated posts sorted by views, likes, and creation date.Cursor for pagination. Pass the last post ID to fetch the next page of results.
Promise<{ rows: Post[], total: number }>
Error Handling: Throws error if fetching fails. Error is logged and re-thrown.
fetchPostsByUserId
Retrieves all posts created by a specific user, sorted by creation date.The ID of the user whose posts to fetch
Promise<{ rows: Post[], total: number }>
Error Handling: Throws error if fetching fails. Error is logged and re-thrown.
searchPosts
Searches posts by content, returning results sorted by views, likes, and creation date.Search query string. If empty or whitespace only, returns all posts via fetchPosts()
Promise<{ rows: Post[], total: number }>
Error Handling: Throws error if search fails. Error is logged and re-thrown.
createPost
Creates a new cricket discussion post.The post content
Array of image URLs. Defaults to empty array.
ID of the post author
Name of the post author
Promise<Post>
Error Handling: Throws error if creation fails. Error is logged and re-thrown.
updatePost
Updates an existing post with partial data.ID of the post to update
Partial post data to update
Promise<Post>
Error Handling: Throws error if update fails. Error is logged and re-thrown.
deletePost
Deletes a post by ID.ID of the post to delete
Promise<void>
Error Handling: Throws error if deletion fails. Error is logged and re-thrown.
executePost
Executes a post action through the posts guard function. This is the recommended way to perform post operations as it includes proper validation and authorization.The action to perform on the post
Post content (required for create and update actions)
Post ID (required for update, delete, like, and view actions)
Array of image URLs (optional for create and update actions)
Promise<Execution>
Error Handling: Throws error if execution fails or status is “failed”. Error is logged and re-thrown.