Expand Record Object Mapping to allow Parameter Mapping#1362
Expand Record Object Mapping to allow Parameter Mapping#1362
Conversation
robsdedude
left a comment
There was a problem hiding this comment.
Review part 1. I'll continue next week with the review. I just want to submit my comments to make sure they don't get lost.
|
Consider making the |
robsdedude
left a comment
There was a problem hiding this comment.
Here goes a first round of comments. Submitting them now so they don't get lost until tomorrow when I shall continue.
| @@ -40,27 +42,25 @@ import Vector from './vector' | |||
| * | |||
| * @property {function(rule: ?Rule & { stringify?: boolean })} asLocalTime Create a {@link Rule} that validates the value is a {@link LocalTime}. | |||
| * | |||
| * @property {function(rule: ?Rule & { stringify?: boolean })} asLocalDateTime Create a {@link Rule} that validates the value is a {@link LocalDateTime}. | |||
| * @property {function(rule: ?Rule & { stringify?: boolean, JSNativeDate?: boolean })} asLocalDateTime Create a {@link Rule} that validates the value is a {@link LocalDateTime}. | |||
| * | |||
| * @property {function(rule: ?Rule & { stringify?: boolean })} asTime Create a {@link Rule} that validates the value is a {@link Time}. | |||
| * | |||
| * @property {function(rule: ?Rule & { stringify?: boolean })} asDateTime Create a {@link Rule} that validates the value is a {@link DateTime}. | |||
| * @property {function(rule: ?Rule & { stringify?: boolean, JSNativeDate?: boolean})} asDateTime Create a {@link Rule} that validates the value is a {@link DateTime}. | |||
| * | |||
| * @property {function(rule: ?Rule & { stringify?: boolean })} asDate Create a {@link Rule} that validates the value is a {@link Date}. | |||
| * @property {function(rule: ?Rule & { stringify?: boolean, JSNativeDate?: boolean})} asDate Create a {@link Rule} that validates the value is a {@link Date}. | |||
| * | |||
| * @property {function(rule: ?Rule)} asPoint Create a {@link Rule} that validates the value is a {@link Point}. | |||
| * | |||
| * @property {function(rule: ?Rule & { apply?: Rule })} asList Create a {@link Rule} that validates the value is a List. | |||
| * | |||
| * @property {function(rule: ?Rule & { asTypedList: boolean })} asVector Create a {@link Rule} that validates the value is a List. | |||
| * | |||
There was a problem hiding this comment.
asVector is missing dimension and type options.
I realized that these options were introduced in the last iteration of this PR... Goes to show how fragile it is to have (more or less) the same docs in two places...
| * @param {mixed} query - Cypher query to execute | ||
| * @param {Object} parameters - Map with parameters to use in query | ||
| * @param {TransactionConfig} [transactionConfig] - Configuration for the new auto-commit transaction. | ||
| * @param {Rules} parameterRules - Rules to typecheck and/or map the parameter object . | ||
| * @param {Rules} parameterRules - Rules to typecheck and/or map the parameter object. Must not be provided as a separate argument if an Object is passed as first argument |
There was a problem hiding this comment.
More of the same question as above. To | undefined or not to | undefined as JShakespeare wrote.
Transaction and managed transaction are other places like this that were touched by this PR. As written about, this is likely a separate piece of work. But at least the newly added parameters should probably
- follow which ever way is right if the whole function is newly added
- or follow whatever other parameters are doing if the function existed or other functions with optional parameters exist in the near vicinity.
There was a problem hiding this comment.
indeed. Aligning this with the transactionConfig parameter.
closes DRIVERS-107
This PR provides support for typechecking and automatic conversion of parameters, as well as using the object mapping registry to register mapping strategies for classes. This lets users directly pass objects even with problematic properties that can not be sent over bolt (like functions), by automatically converting them or by omitting them from the mapping strategy.
This is the 2nd half of the Record Object Mapping feature, which is also marked stabilized and taken out of preview in this PR.
Examples