Skip to content

Instantly share code, notes, and snippets.

@mcjcloud
Created July 10, 2020 06:45
Show Gist options
  • Save mcjcloud/27ba14740e37ba3c773b9f161b00230d to your computer and use it in GitHub Desktop.
Save mcjcloud/27ba14740e37ba3c773b9f161b00230d to your computer and use it in GitHub Desktop.
Asterisk Medium Article: services
/**
* mark a todo as incomplete
*/
export const uncompleteTodo = async (_id: string): Promise<TodoItem> => {
const todoCollection = await useCollection<TodoItem>("todo")
const { result } = await todoCollection.updateOne({ _id }, {
$set: { complete: false },
})
if (!result.ok) {
throw new Error("Could not uncomplete TodoItem")
}
return await getTodoByID(_id)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment