Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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