Skip to content

Commit 1733c3d

Browse files
committed
Use lodash 4 methods
1 parent 16cc5c5 commit 1733c3d

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,23 @@ db._.mixin({
189189
}
190190
})
191191

192-
const song1 = db('songs').first()
193-
const song2 = db('songs').second()
192+
const post1 = db('posts').first()
193+
const post2 = db('posts').second()
194194
```
195195

196196
__db.object__
197197

198198
Use whenever you want to access or modify the underlying database object.
199199

200200
```js
201-
db.object // { songs: [ ... ] }
201+
db.object // { posts: [ ... ] }
202202
```
203203

204204
If you directly modify the content of the database object, you will need to manually call `write` to persist changes.
205205

206206
```js
207207
// Delete an array
208-
delete db.object.songs
208+
delete db.object.posts
209209
db.write()
210210

211211
// Drop database
@@ -247,49 +247,49 @@ Also, the execution of chained methods is lazy, that is, execution is deferred u
247247

248248
#### Examples
249249

250-
Sort the top five songs.
250+
Sort the top five posts.
251251

252252
```js
253-
db('songs')
253+
db('posts')
254254
.chain()
255-
.where({published: true})
255+
.filter({published: true})
256256
.sortBy('views')
257257
.take(5)
258258
.value()
259259
```
260260

261-
Retrieve song titles.
261+
Retrieve post titles.
262262

263263
```js
264-
db('songs').pluck('title')
264+
db('posts').map('title')
265265
```
266266

267-
Get the number of songs.
267+
Get the number of posts.
268268

269269
```js
270-
db('songs').size()
270+
db('posts').size()
271271
```
272272

273-
Make a deep clone of songs.
273+
Make a deep clone of posts.
274274

275275
```js
276-
db('songs').cloneDeep()
276+
db('posts').cloneDeep()
277277
```
278278

279-
Update a song.
279+
Update a post.
280280

281281
```js
282-
db('songs')
282+
db('posts')
283283
.chain()
284284
.find({ title: 'low!' })
285285
.assign({ title: 'hi!'})
286286
.value()
287287
```
288288

289-
Remove songs.
289+
Remove posts.
290290

291291
```js
292-
db('songs').remove({ title: 'low!' })
292+
db('posts').remove({ title: 'low!' })
293293
```
294294

295295
### How to use id based resources
@@ -303,17 +303,17 @@ const db = low('db.json')
303303

304304
db._.mixin(require('underscore-db'))
305305

306-
const songId = db('songs').insert({ title: 'low!' }).id
307-
const song = db('songs').getById(songId)
306+
const postId = db('posts').insert({ title: 'low!' }).id
307+
const post = db('posts').getById(postId)
308308
```
309309

310310
[uuid](https://github.com/broofa/node-uuid) is more minimalist and returns a unique id that you can use when creating resources.
311311

312312
```js
313313
const uuid = require('uuid')
314314

315-
const songId = db('songs').push({ id: uuid(), title: 'low!' }).id
316-
const song = db('songs').find({ id: songId })
315+
const postId = db('posts').push({ id: uuid(), title: 'low!' }).id
316+
const post = db('posts').find({ id: postId })
317317
```
318318

319319
### How to use custom format

0 commit comments

Comments
 (0)