Giter Site home page Giter Site logo

Comments (7)

dkebler avatar dkebler commented on September 14, 2024 2

This is still an issue 4.0. Couldn't either access after create with .persistence or didn't grok how except via .__original.persistence

So decided to extend your class for easier access

Maybe some/all worthy of incorporating?

class DataStore extends NEDBP {
  constructor(opts){
    super(opts)
  }

  indexes () {
    return this.__original.indexes
  }

  compact () {
    this.__original.persistence.compactDatafile()
  }

  autoCompact(interval) {
    this.__original.persistence.setAutocompactionInterval(interval)
  }

  async get (id) {
    let doc = await this.findOne({_id:id})
    return doc[id] ? doc[id] : doc
  }

  nedb() {
    return this.__original
  }
}

from nedb-promises.

bajankristof avatar bajankristof commented on September 14, 2024

Hey there!
Sorry for the delayed answer, I have been busy.
It's been a long time and by now it is probably irrelevant but this should be fixed with 1.1.2's new Datastore.create method. If you want to, check out that version and see if this issue can be closed or not.

from nedb-promises.

catmade avatar catmade commented on September 14, 2024

Same issue in 4.1.0 with TypeScript.

from nedb-promises.

catmade avatar catmade commented on September 14, 2024

I use the following code to work correctly

import Nedb from "nedb-promises";

let nedb = new Nedb({...});

let nedbAny: any = nedb;
nedbAny.__original.persistence.setAutocompactionInterval(1);

from nedb-promises.

bajankristof avatar bajankristof commented on September 14, 2024

Can you elaborate what is and what isn't working? Is it the autocompletion? Does typescript not compile because it thinks persistence is not a property of the datastore? What's the issue here exactly?
Because in pure node JS using Datastore.create I can access persistence without any problem:

datastore.persistence.mov

from nedb-promises.

catmade avatar catmade commented on September 14, 2024

It's just the autocompletion problem 😑! The index.d.ts file caused this problem.

from nedb-promises.

bajankristof avatar bajankristof commented on September 14, 2024

Thanks to @catmade the typescript definition file was fixed in #36 and published to npm in 4.1.1. This should not be an issue from now on.

from nedb-promises.

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.