Created
December 29, 2020 17:52
-
-
Save lydemann/9bdeb6d7c53dd1f1a14e092d6cdfb240 to your computer and use it in GitHub Desktop.
user-resolvers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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