-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add PouchDB Context store plugin #1
base: main
Are you sure you want to change the base?
Conversation
|
||
- Data is saved in the JSON object format supported by PouchDB. The plugin does not convert JSON data to a string for storage. | ||
|
||
Code example that references database data : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So where does this code sit ? Is this totally external to Node-RED ? Or is it (or should it be) an example in a function node ? or ???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code example is supposed to be executed externally, and can also be run in the function node.
When executing in the function node, set the functionGlobalContext in setting.js so that PouchDB can be used in the function node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe worth adding that as a "how-to" in the readme. (probably more applicable to the events example though).
This allows you to back up the data stored in your local SQLite to a remote CouchDB.This allows you to back up context data stored in your local SQLite to a remote CouchDB. | ||
|
||
- In an environment with multiple context stores, only contexts using the PouchDB plugin will be backed up. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise where does this code sit ? I see that it creates events ? Can they be used in Node-RED ?
If I had two machines replicating some part of global context ... how could I get a trigger on machine B that said that machine A had updated my context, so I should re-read it, and update my dashboard, for example ?
Not sure if this is in this plugin or in core... If I use a function node to try to get from the context it fails with a "callback must be a function" error. It works fine with change node. Works OK if I specify "memory" or "file" as second parameter. Simple test case
|
PouchDB plugin and Redis plugin only supports asynchronous access. This flow supports asynchronous access.
|
OK- could the error message be changed to suggest that possibility ? Not that is must be a function - but that it must exist :-) - Maybe an extra test - if callback === undefined ... say that it is async and a callback must be defined
Or something ??? |
Isn't the error coming from the core? |
no - it's coming from that line 160 highlighted above (so no i18n :-) ) |
Change the message to the suggested one. |
I think you need to add it as well... so if undefined throw that error - and if defined but not a function then throw the error that you were doing. |
Two updates have been made to address your suggestions.
|
👍 (I notice you also applied same "fix" to redis plugin... thanks) |
Proposed changes
This makes it possible to store context data to PouchDB.
The design note is https://github.com/node-red/designs/blob/master/designs/pouchdb-context-plugin.md
Checklist
grunt
to verify the unit tests pass