Nested object
While kysely is not an ORM and it doesn't have the concept of relations, we do provide
helpers for fetching nested objects and arrays in a single query. In this example we
use the jsonObjectFrom
helper to fetch person's favorite pet along with the person's id.
Please keep in mind that the helpers under the kysely/helpers
folder, including
jsonObjectFrom
, are not guaranteed to work with 3rd party dialects. In order for
them to work, the dialect must automatically parse the json
data type into
javascript JSON values like objects and arrays. Some dialects might simply return
the data as a JSON string. In these cases you can use the built in ParseJSONResultsPlugin
to parse the results.
The API documentation is packed with examples. The API docs are hosted here but you can access the same documentation by hovering over functions/methods/classes in your IDE. The examples are always just one hover away!
For example, check out these sections: