Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created December 29, 2020 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lydemann/9bdeb6d7c53dd1f1a14e092d6cdfb240 to your computer and use it in GitHub Desktop.
Save lydemann/9bdeb6d7c53dd1f1a14e092d6cdfb240 to your computer and use it in GitHub Desktop.
user-resolvers.ts
setLessonCompleted: (
parent,
{ uid, lessonId, isCompleted },
context: RequestContext
) => {
if (!context.auth.admin && uid !== context.auth.uid) {
throw new AuthenticationError('User is not admin or user');
}
return firestoreDB
.doc(
`schools/${context.auth.schoolId}/users/${uid}/userLessonsCompleted/${lessonId}`
)
.set({
completed: isCompleted,
lessonId,
lastUpdated: FieldValue.serverTimestamp()
})
.then(() => `Got updated`);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment