Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query by timestamp and upgrade path #683

Closed
CanisHelix opened this issue Jun 14, 2018 · 2 comments
Closed

Query by timestamp and upgrade path #683

CanisHelix opened this issue Jun 14, 2018 · 2 comments

Comments

@CanisHelix
Copy link

I'm starting a new cross-platform project and looking for a JSON DocumentStore, is LokiJS supported on Node 10.x officially?

Is it possible to provide examples on how to query for items in a collection that are older than x days/hours etc? i.e. I'm looking to auto-purge old data

And what would the upgrade path from LokiJS to LokiDB look like in the future? Would it require a complete rewrite of my application or just a few changes?

@obeliskos
Copy link
Collaborator

obeliskos commented Jun 16, 2018

Support for Node 10.x? Of course.

We do have one feature 'autoupdate' which is deprecated though, we should probably go ahead and remove that but we may possible. It is not enabled by default so don't turn on that option in collection constructor and expect it to work. If you would like to see a similar feature in LokiDb, but based on proxies, chime in over there regarding that feature.

We have TTL functionality which should be able to do what you are requesting, automatically. You can either look into the 'ttl' and 'ttlInterval' options on the Collection constructor or you could manually search and remove based on our built-in 'meta' object properties, such as :

var dt = new Date("1/1/2018").getTime();
coll.findAndRemove({ "meta.created": { $lte: dt });
//or
coll.findAndRemove({ "meta.updated": { $lte: dt });

Upgrade from LokiJS to LokiDB is being worked on right now ... feel free to chime in over there.

@CanisHelix
Copy link
Author

Thanks ever so much for the clear and concise answers. I don't believe I will need the autoupdate feature myself so I should be safe.

Keep up the good work, and really appreciate the online sandbox for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants