When using the TraversedJSONPathBuilder, I often find myself needing to strip undefined from the resulting type, which $notNull is not sufficient for, and $castTo ends up being verbose. For example:
db.selectFrom('elements')
.select(eb => [
'id',
eb.ref('data', '->$')
.key('flags')
.$castTo<Exclude<ElementData['flags'], undefined>>()
.as('flags'),
])
.where(eb => eb(eb.ref('data', '->$').key('flags'), 'is not', null))
With this, I was wondering if perhaps the type returned by TraversedJSONPathBuilder should use null instead of undefined since the database doesn't actually returned undefined in these cases, does it? Or if it does, then a $notUndefined may be more appropriate?
When using the
TraversedJSONPathBuilder, I often find myself needing to stripundefinedfrom the resulting type, which$notNullis not sufficient for, and$castToends up being verbose. For example:With this, I was wondering if perhaps the type returned by
TraversedJSONPathBuildershould usenullinstead ofundefinedsince the database doesn't actually returnedundefinedin these cases, does it? Or if it does, then a$notUndefinedmay be more appropriate?