From 3e588f83c17290fb18c3a020bc8e9902e6649758 Mon Sep 17 00:00:00 2001 From: typicode Date: Wed, 18 Oct 2023 23:48:06 +0200 Subject: [PATCH] docs: update --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index be8d8fa..e2e84ee 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,13 @@ > Simple to use local JSON database. Use native JavaScript API to query. Written in TypeScript. 🦉 ```js +// Read or create db.json +const db = await JSONPreset('db.json', { posts: [] }) + // Edit db.json content using plain JavaScript -db.data.posts.push({ id: 1, title: 'lowdb is awesome' }) +db.data + .posts + .push({ id: 1, title: 'lowdb is awesome' }) // Save to file db.write() @@ -61,6 +66,7 @@ _Lowdb is a pure ESM package. If you're having trouble using it in your project, ```js import { JSONPreset } from 'lowdb/node' +// Read or create db.json const defaultData = { posts: [] } const db = await JSONPreset('db.json', defaultData)