https://github.com/gustavocadev/db
dbjson gonna help you to write and read json files easily 🦕
https://github.com/gustavocadev/db
deno json typescript
Last synced: about 2 months ago
JSON representation
dbjson gonna help you to write and read json files easily 🦕
- Host: GitHub
- URL: https://github.com/gustavocadev/db
- Owner: gustavocadev
- License: mit
- Created: 2022-02-09T13:57:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-23T17:30:29.000Z (over 3 years ago)
- Last Synced: 2026-03-21T21:53:48.838Z (3 months ago)
- Topics: deno, json, typescript
- Language: TypeScript
- Homepage: https://deno.land/x/dbjson
- Size: 14.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Dbjson
Bbjson gonna help you to interact with your json files that way you can use it
as a database, but with a simple form to do it
```typescript
// we import the module
import { DbJSON } from 'https://deno.land/x/dbjson@LATEST_VERSION/mod.ts'
// we define the type
type User = {
name: string
age: number
id: string
}
// we need to choose the relative path of our db.json and the entry name of our json
const db = new DbJSON('./db/db.json', 'users')
const { users } = await db.readJSON()
users.push({
name: 'tobi',
age: 16,
id: crypto.randomUUID(),
})
// this gonna write it in the place and with name we choose it in the instance we did in "new Dbjson"
await db.writeJSON(users)
console.log(users) // [{ name: "tobi", age: 16, id: '6cb9248a-232f-4011-8a05-b315157fdfe5' }]
```