Giter VIP home page Giter VIP logo

Comments (2)

yoshuawuyts avatar yoshuawuyts commented on July 20, 2024 5

Hey! So umm, yeah we switched and I guess we forgot to update the README haha. Because indexedDB requires migrations, and some other things - it was tricky to make it work as a 1:1 sync module. That's why we ended up using localStorage instead.

If you want to use indexedDB, check out nanoidb. You can then quite easily copy this module's behavior, doing something like:

var nanoidb = require('nanoidb')
var choo = require('choo')

var app = choo()
app.use((state, emitter) => {
  var db = nanoidb('butts', 1)
  db.on('upgrade', function (diffData) {
    diffData.db.createObjectStore('main')
  })

  db.on('open', (stores) => {
    var store = stores.main

    emitter.on('*', () => {
      // Like don't actually do this, but it's sorta the same idea haha.
      // Just _very_ poorly performing lmao.
      var tx = store.batch()
      Object.keys(state).forEach(function (key) {
        tx.put(key, state[key]) // make sure to stringify correctly, perhaps even go recursive
      })
      tx.flush(function (err) {
        if (err) throw err // proper error handling needed
        console.log('done well!')
      })
    })
  })
})

Hope this helpful!

from choo-persist.

DougAnderson444 avatar DougAnderson444 commented on July 20, 2024

Perf, I'll try this! Just so you know.... the description is still saying IndexedDB. Which led me to an issue search, which led me to here. But it's still erroneous on the descrip' page ;)

from choo-persist.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.