Optional fields inside tuple parameters
Request
Add support for optional fields inside tuple parameters inside e.params({ ... }) arguments. This would allow for an implicit JSON to EdgeDB mapping inside the query.run(client, {...}) method while not having to cast every single parameter by hand using e.json params.
Syntax
Why not use the already existing e.optional() allowed in the top level properties of e.params({}) argument, and possibly implement it this way:
e.params({
tupleParameter: e.tuple({
requiredParam: e.int32,
optionalParam: e.optional(e.int32), // Optional int32 parameter
})
}, ...);
This would allow to use the query.run(client, {...}) method like so (or by simply passing the correct object as parameters):
const requiredNumberParameter: number = 42;
const optionalNumberParameter: number | null = null;
e.run(client, {
tupleParameter: {
requiredParam: requiredNumberParameter,
optionalParam: optionalNumberParameter,
})
});
Thank you in advance.
+1 for this.
Here are the related discord threads:
- https://discord.com/channels/841451783728529451/1079834474415656990
- https://discord.com/channels/841451783728529451/1070149803729752165
Typing e.params() using e.array() and e.tuples() instead of e.json() is much more enjoyable, but lack of optionals prevents in many cases
+1 for this please