+25
-1
example/.github/copilot-instructions.md
+25
-1
example/.github/copilot-instructions.md
···
127
127
128
128
```ts
129
129
await Deno.writeTextFile("data/hello.txt", "Hello World");
130
+
131
+
const content = await Deno.readTextFile("data/hello.txt");
132
+
console.log(content); // Hello World
130
133
```
131
134
132
-
### SQLite
135
+
### Using a JSON file as a database
136
+
137
+
```ts
138
+
import { JSONFilePreset } from "npm:lowdb/node"
139
+
140
+
const db = await JSONFilePreset('data/db.json', { posts: [] })
141
+
142
+
// read existing posts
143
+
console.log(db.data.posts)
144
+
145
+
// add new post
146
+
const post = { id: 1, title: 'lowdb is awesome', views: 100 }
147
+
148
+
// In two steps
149
+
db.data.posts.push(post)
150
+
await db.write()
151
+
152
+
// Or in one
153
+
await db.update(({ posts }) => posts.push(post))
154
+
```
155
+
156
+
### Using SQLite
133
157
134
158
```ts
135
159
import { DatabaseSync } from "node:sqlite";