1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <template> <div> <h2>DB Items</h2> <button @click="db.items.add({ name: `Another item` })">Add item</button> <button @click="db.items.clear()">Clear items</button> <ul> <li v-for="item in items" :key="item.id"> {{ item.id }}, {{ item.name }} </li> </ul> </div> </template> <script> import { liveQuery } from "dexie"; import { db } from "../db"; import { useObservable } from "@vueuse/rxjs";
export default { name: "DBItems", setup() { return { db, items: useObservable( liveQuery(() => db.items.where("name").startsWith("A").toArray()) ), }; }, }; </script>
|