Skip to content
Kohei Asai edited this page Apr 5, 2020 · 15 revisions

Get post(s)

TBD

Create a post

TBD

Get answer(s)

TBD

Create an answer to a post

Create a Firestore document to /posts/{postId}/answers/{answerId}.

Restriction

  • Needs to be authenticated

Data

Key Type Conditions
post Reference It must point to the parent document (/posts/{postId}).
user Reference It must point to the request user itself (/users/{userId}).
body String It needs to be more than or equal 8 character length and less than 65536 character length.
likes Integer It must be 0.
dislikes Integer It must be 0.
createdAt Timestamp It must be FieldValue.serverTimestamp()

Delete an answer from a post

Delete a Firestore document at /posts/{postId}/answers/{answerId}.

Restriction

  • Needs to be authenticated
  • The target answer's user is the request user

Get comment(s)

TBD

Create a comment to an answer

Create a Firestore document to /posts/{postId}/answers/{answerId}/comments/{commentId}.

Restriction

  • Needs to be authenticated

Data

Key Type Conditions
answer Reference It must point to the parent document (/posts/{postId}/answers/{answerId}).
user Reference It must point to the request user itself (/users/{userId}).
body String It needs to be more than or equal 8 character length and less than 65536 character length.
likes Integer It must be 0.
dislikes Integer It must be 0.
createdAt Timestamp It must be FieldValue.serverTimestamp()

Delete a comment from an answer

Delete a Firestore document at /posts/{postId}/answers/{answerId}/comments/{commentId}.

Restriction

  • Needs to be authenticated
  • The target comment's user is the request user

Check if liked/disliked an answer

TBD

Like or dislike an answer

Create a Firestore document to /posts/{postId}/answers/{answerId}/reactions/{auth.uid}.

Restriction

  • Needs to be authenticated

Data

Key Type Conditions
answer Reference It must point to /posts/{postId}/answers/{answerId}. The document that the reference points to needs to exists.
user Reference It must point to /users/{auth.uid}.
type "LIKE" or "DISLIKE" "LIKE" to like or "DISLIKE" to dislike.

Undo like or dislike an answer

Delete the Firestore document at /posts/{postId}/answers/{answerId}/reactions/{auth.uid}.

Restriction

  • Needs to be authenticated

Check if liked/disliked a comment

app
  .firestore()
  .collection("posts")
  .doc(post.id)
  .collection("answers")
  .doc(answer.id)
  .collection("comments")
  .doc(comment.id)
  .collection("reactions")
  .doc(user.id)
  .get();

Restriction

  • Needs to be authenticated

Data

Key Type Conditions
user Reference The user who liked/disliked the comment. It should point the request user.
type "LIKE" or "DISLIKE" "LIKE" to like or "DISLIKE" to dislike.

Like or dislike a comment

Create a Firestore document to /posts/{postId}/answers/{answerId}/comments/{commentId}/reactions/{auth.uid}.

Restriction

  • Needs to be authenticated

Data

Key Type Conditions
comment Reference It must point to /posts/{postId}/answers/{answerId}/comments/{commentId}. The document that the reference points to needs to exists.
user Reference It must point to /users/{auth.uid}.
type "LIKE" or "DISLIKE" "LIKE" to like or "DISLIKE" to dislike.

Undo like or dislike a comment

Delete the Firestore document at /posts/{postId}/answers/{answerId}/comments/{commentId}/reactions/{auth.uid}.

Restriction

  • Needs to be authenticated