lessonDuration 4m 58sFree
Create, read, update, delete. Four actions that every developer becomes intimately familiar with over their career. Script Kit aims to make this process as pleasant as possible using a `db` helper and what better way to show it off than a Todos app?
You will also learn how to create and switch between tabs through Script Kit's `onTab` and `setTab` methods.
[Install todos](https://scriptkit.com/api/new?name=todos&url=https://gist.githubusercontent.com/johnlindquist/3bdc967ffbd2f6d72491d07bf720f7e2/raw/a37b0058b502d6ba4bebd7a31a30be8789f5a146/todos.js")
```js
// Name: Todos
import "@johnlindquist/kit"
let { todos, write } = await db({ todos: [] })
onTab("Todos", async () => {
while (true) {
let todo = await arg("Toggle todo:", todos)
let t = _.find(todos, todo)
t.tag = t.tag === "open" ? "done" : "open"
await write()
}
})
onTab("New", async () => {
let name = await arg("New todo:")
todos.push({ name, id: uuid(), tag: "open" })
await write()
setTab("Todos")
})
onTab("Remove", async () => {
let todo = await arg("Remove todo:", todos)
_.remove(todos, todo)
await write()
setTab("Todos")
})
```