Skip to content

Instantly share code, notes, and snippets.

@abelaska
Created September 11, 2016 17:13
Show Gist options
  • Save abelaska/19ef5c38cf6fb49db5661e29ae819c7b to your computer and use it in GitHub Desktop.
Save abelaska/19ef5c38cf6fb49db5661e29ae819c7b to your computer and use it in GitHub Desktop.
try {
await UserSession.get(ctx.id).update({ pingedAt: r.now() }, { durability: 'soft' });
} catch (e) {
if (e.name === 'DocumentNotFoundError') {
await UserSession
.insert({ id: ctx.id, userId: ctx.user.id, pingedAt: r.now() }, { durability: 'soft' });
} else {
log.error(`Failed to update user session ${ctx.id}`, {
error: err
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment