Comments (7)
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.
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.
Same issue in 4.1.0 with TypeScript.
from nedb-promises.
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.
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.
It's just the autocompletion problem 😑! The index.d.ts file caused this problem.
from nedb-promises.
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)
- Count by timestamp HOT 2
- typescript interfaces errors HOT 1
- How to extends Document ? HOT 1
- Datastore not generic HOT 3
- support nedb package as plugin HOT 1
- Return value of `find().exec()` is `T[][]`, should be `T[]`
- high severity vulnerability HOT 11
- Q: Can I use camo with nedb-promises? HOT 1
- How can I use this via the <script> tag? HOT 1
- [BUG] ensureIndex duplicating HOT 3
- Datastore file didnt get created HOT 7
- . HOT 3
- findOne gives type <T> but can be null HOT 7
- TypeScript (plus suggestions and auto import in VS Code) fail due to inaccurate TypeScript declaration HOT 1
- Support for @seald-io/[email protected] (and later) HOT 3
- Package contains a reference to a license without a matching LICENSE file. HOT 2
- Add `updateOne` and `updateMany` over `update` HOT 4
- Error: 100% of the data file is corrupt, more than given corruptAlertThreshold (10%) HOT 1
- webpack 5 compatibility HOT 1
- adding new entry on update HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nedb-promises.