Giter Club home page Giter Club logo

Comments (6)

julien235 avatar julien235 commented on May 25, 2024

Hi,

Same issue when I used with cucumber-js tests :(

from data-store.

wavpro avatar wavpro commented on May 25, 2024

Hi,

Same issue when I used with cucumber-js tests :(
@julien235

Seems like it has to do with multiple declared stores. If you have multiple files you can try passing the store through functions.

from data-store.

doowb avatar doowb commented on May 25, 2024

Do either of you have any code to demonstrate the issue you're having?

from data-store.

wavpro avatar wavpro commented on May 25, 2024

from data-store.

skeddles avatar skeddles commented on May 25, 2024

i believe it keeps a working version in memory, it definitely doesn't update the values based on changes to the file, until you restart the software and reload it. if you are including them both in the same application, i would establish it once in the main file and make the instance available globally so you can access it from multiple files. if you cant do that (maybe its across multiple apps), you probably want a database instead.

from data-store.

Knoot avatar Knoot commented on May 25, 2024

I'm using a single file but creating multiple store instances to limit the scope of individual classes. Faced with the fact that deleted data was returned when trying to write to a file. I also use a wrapper for store.

This is a bad solution, but this helped:

const config = require('../config.js')

export class DB {

    private get db() {
        const db: any = require('data-store')({ path: process.cwd() + config.dbPath })

        if (this.prefix && !db.has(this.prefix)) {
            db.set(this.prefix, {})
        }

        return db
    }

    constructor(private prefix?: string) {}

    get(key?: string): any {
        if (this.prefix && key) {
            return this.db.get(`${this.prefix}.${key}`)
        }

        if (this.prefix && !key) {
            return this.db.get(this.prefix)
        }

        if (key) {
            return this.db.get(key)
        }

        return undefined
    }

    //other methods...
}

from data-store.

Related Issues (20)

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.