@@ -161,19 +161,22 @@ low('db.json', {
161161})
162162```
163163
164- Full method signature :
164+ You can also define custom storages and formats :
165165
166166``` js
167- low (source, {
168- storage: {
169- read : (source , deserialize ) => // obj or a Promise
170- write : (dest , obj , serialize ) => // undefined or a Promise
171- },
167+ const myStorage = {
168+ read : (source , deserialize ) => // obj or a Promise
169+ write : (dest , obj , serialize ) => // undefined or a Promise
170+ }
171+
172+ const myFormat = {
172173 format: {
173174 deserialize : (data ) => // obj
174175 serialize : (obj ) => // data
175176 }
176- }, writeOnChange)
177+ }
178+
179+ low (source, { storage: myStorage, format: myFormat }, writeOnChange)
177180```
178181
179182__ db.___
@@ -213,12 +216,24 @@ db.write()
213216
214217__ db.write([ source] )__
215218
216- Persists database using ` storage.write ` method.
219+ Persists database using ` storage.write ` method. Depending on the storage, it may return a promise.
220+
221+ Note: by default, lowdb automatically calls it when database changes.
217222
218223``` js
219- const db = low (' db.json' )
220- db .write () // writes to db.json
221- db .write (' copy.json' ) // writes to copy.json
224+ const db = low (' db.json' , { storage })
225+ db .write () // writes to db.json
226+ db .write (' copy.json' ) // writes to copy.json
227+ ```
228+
229+ __ db.read([ source] )__
230+
231+ Reads source using ` storage.read ` method. Depending on the storage, it may return a promise.
232+
233+ ``` js
234+ const db = low (' db.json' , { storage })
235+ db .read () // re-reads db.json
236+ db .read (' copy.json' ) // reads copy.json
222237```
223238
224239## Guide
0 commit comments