Copyright | (c) Aaron Allen 2020 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Aaron Allen <aaronallen8455@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- jsonPath :: (TypeAtPath o tree path ~ field, ReflectPath path, IsPgJSON json, Coercible (json field) (JNullable json' field)) => proxy (path :: k) -> ObjectTree tree o -> QGenExpr ctxt Postgres s (json o) -> QGenExpr ctxt Postgres s (JNullable json' field)
- newtype JNullable json a = JNullable (json a)
- nullableJsonb :: forall a. (ToJSON a, FromJSON a) => DataType Postgres (JNullable PgJSONB a)
- nullableJson :: forall a. (ToJSON a, FromJSON a) => DataType Postgres (JNullable PgJSON a)
Documentation
:: (TypeAtPath o tree path ~ field, ReflectPath path, IsPgJSON json, Coercible (json field) (JNullable json' field)) | |
=> proxy (path :: k) | A path proxy |
-> ObjectTree tree o | Typson schema |
-> QGenExpr ctxt Postgres s (json o) | Column selector |
-> QGenExpr ctxt Postgres s (JNullable json' field) |
Use a type-safe JSON path as part of a query.
select $ jsonPath (Proxy @("foo" :-> "bar")) fieldSchemaJ . fieldAccessor <$> all_ someTable
newtype JNullable json a Source #
Wraps a PgJSON
or PgJSONB
, treating deserialization of SQL NULL
as
json null
. This is so that if you query for a path that might not exist,
i.e. a path into an optional field, then an exception will not be raised
when attempting to decode the result as JSON.
JNullable (json a) |