underscore-query icon indicating copy to clipboard operation
underscore-query copied to clipboard

Make it pluggable to lowdb

Open aegyed91 opened this issue 8 years ago • 1 comments

Hello, first of all i have to say this is an awesome library.

I've tried to augment lowdb with this mixin lib. Unfortunately without success.

import low from 'lowdb'
const db = low('db')

// `underscore-query` doesn't expose an object of mixins
db._.mixin({
  second: function(array) {
    return array[1]
  }
})

I usually use native js methods for data manipulation but it seems i'll have to create my first SPA application soon and these two libraries would play awesome together so i can easiely manipulate state and persist it to localstorage or even indexed db with a custom lowdb storage adapter.

I short quote from lowdb's readme:

Database lodash instance. Use it to add your own utility functions or third-party mixins like underscore-contrib or underscore-db.

ping @davidgtonge @megawac @typicode

aegyed91 avatar Aug 06 '16 13:08 aegyed91

Hi all,

Based on the README, I think it should be possible to do the following:

const low = require('lowdb')
const underscoreQuery = require('underscore-query')
const db = low()

// Add query to the db lodash instance
underscoreQuery(db._)

typicode avatar Aug 11 '16 12:08 typicode