-
Notifications
You must be signed in to change notification settings - Fork 29
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
Non-replicating (local) / replication-only transformation functions #37
Comments
There's also the matter of how, with these as available functions, they'd interact if specified alongside One way to do it would be to make them mutually exclusive, with any use of plain
In other words, that documents would pass through (at most) three transformations before coming into / going out from the database, depending on the function:
And, of course, these only apply if specified. Applications could need as few as only one transformation function to specify (ie. transforming incoming documents only from replication, for the purposes of migration), or could require as many as all eight (needing to perform a common transformation to the outside incoming document format, transforming that further when inserting and also for replication from outside, finalizing both of those source-specific changes in a common way, performing a common pre-transformation out of the database, altering that further in specific ways, and then putting one last set of common finishing touches on), or any number of other combinations (most would probably use no more than six, but it could realistically be any six). |
Also, something that just occurred to me: it might make sense for transformation functions to have access to data about the transaction or replication as a second parameter. For example, this would allow an outgoing replication function to strip local-application-specific fields when replicating to remote databases. Indeed, now that I think about it, this might be the more sensible level to factor this at: a second parameter that functions could use to filter and compose their own outgoing or incoming transformations as applicable, whether that be on a local-versus-replication basis, or whatever. |
#38 makes a good point on how these are fundamentally different operations, and should really be handled completely differently: an incoming or outgoing transformation from the out-of-database world may not correspond to a revision to a document, but a transformation in the process of replication absolutely does. In that light (assuming |
Well, either that, or there could be a separate In any case, I think |
I'm starting to think that, yes, it would make sense to make a separate plugin. This plugin is designed for very simple use cases, e.g. I have a CouchDB full of too-big documents and I merely want them to be smaller when I replicate them locally. You are fully encouraged to write a |
I second Nolan’s comment, but please keep us posted on revise-pouch :) |
It would make a lot of sense - especially for applications that maintain a special in-DB representation of data that should be replicated without transformation, like, say,
crypto-pouch
- if there were variants likeincomingLocal
,outgoingLocal
,incomingReplication
, andoutgoingReplication
, where the latter two only apply for replication, and the former only apply for non-replicating actions (get
,put
, etc).I guess this can be emulated right now by doing something like this:
but that would lead to issues, with, say, a general function that takes one database as an argument, on which it performs both replication and non-replication operations.
Also, does
new PouchDB(dbTransformHasAlreadyBeenCalledOn)
copy the transformations that are on that DB? My gut says it should, but I'm not certain (and I'm not sure if the docs make any statement on the matter one way or another).The text was updated successfully, but these errors were encountered: