-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
inMemory collections don't implement static methods #744
Comments
Thats a feature lack. Thanks for reporting. Im on holidays for a few weeks so this will take some time until I fix it. |
Related to this, they also don't inherit the options property of the parent. Just leaving it here for reference |
Hi Daniel. I have invested quite a bit of time playing with RxDB these past days. It seems to me like, now that we have For those reasons, I would suggest to remove I would close the issue, but not sure if you'll agree; let me know what you think! |
The things that are optimiseable by the query-change-detection are limited. Depending on what type of queries you do, it might be possible that next to every query runs against the hard-drive. I fixed the original issue, I will think about your arguments a bit more but close this issue for now. |
That makes total sense. If you feel like you could share it, it'd be great to have the insight those tests gave you so we'd know specifically which use cases suit them best. In any case, if inMemory collections are kept in RxDB, I'd like to suggest a different way of handling these. As things are right now, we're creating a new type of collections that are not accessible on the collections object of the DB and we are responsible to pass around to use and handle separately. They also have a different lifecycle than their equivalents, and are not used internally for population. Instead of duplicating all the code and having a different type of collections that are "in memory", I would propose that The only downside I can see is we wouldn't have two separate instances, which I personally would view as an upside as it makes dealing with them more straightforwards, and I can't see a use case for the opposite. And even if there are extreme use cases, there's probably a case to be made for simplifying the inMemory api, which will benefit most people using it, in exchange for dropping support for these - which would nevertheless be achievable with a little bit of more code on the user part. Let me know what you think! |
I can not share my tests, but it is basically about handling data for time-tracking. For example if i want to display all entries that are younger than one hour, I would write a query like I see a problem with changing the internal pouchdb: Another thing is, that it was planned to allow adding a RxQuery when you call I will try to fix all issues with the current inMemory-implementation in the next days and maybe I have a different opinion then :) |
You're absolutely right on your point. One solution I can think of is for the create/update/delete queries no to resolve until they're written on both, while all queries run again the memory one. But even then it wouldn't allow for your planned implementation of allowing subsets of the collection to be in memory, which I can see a few use cases for. I think it'd be good to stick with your original plan forwards. However, following your appreciation in that "you would not know if the operation is written into the memory-pouch or the one before", that's also the case for in memory collections as they are - when we write to them, which we'll inevitably do if we recover docs from it through any query and want to write on the docs. There might be a case to be made for replacing all create/update/delete ops so they operate on the non in memory pouch db underlying instance, while reads occur in memory. Also, are they inheriting hooks too after the rewrite? |
This is a great idea. We should try doing writes directly to the parent-collection and only do queries at the in-memory. I will add this to the road of No I have not touched the hooks. |
Great! Regarding hooks, as writes would go to the permanent storage pouchdb instance, I'm thinking it would make sense to apply the same hooks as the parent collection does. What do you think? Edit: I was reflecting some more on the idea of not creating a separate instance but realized what I was proposing would be easily done with a plugin, as your proposed solution would be more flexible. |
@rafamel I changed the in-memory-plugin so writes now go directly to the parent collection and it is awaited until the write was replicated. I do not think we should copy the middleware-hooks because they are not set when the collection is created, but afterwards by calling Also I am not sure what should happen when the hook is copied and I run an insert on a document. Because we do the write to the parent collection, does that mean that the hook runs twice? With the current implementation, only the preInsert-hook of the inMemory-collection would run. Maybe you see a use-case where copying the hook is a better solution? |
I am closing this because the original issue is resolved. |
Case
Not sure on whether it is a bug or just a feature lack.
Issue
inMemory collections don't implement static methods available for the parent collection.
Info
Code
The text was updated successfully, but these errors were encountered: