Skip to content

Add ability to hydrate refs when getting from DataTypes #1043

@RangerMauve

Description

@RangerMauve

Description

A lot of datatypes have refs to other objects consisting of core id + version id. This is needed to get a doc from another collection (basically a join). Right now consumers of core need to do these joins at the application level which can be complex when there's several fields to manage accross queries. We should provide a way to hydrate these refs at the getMany or getById level.

e.g. dream API:

project.observation.getByDocId(docId, { include: { track: true })

Tasks

(TODO: Bikeshed approach)

  • Settle on API for consumers (I think a list of fields to hydrate would be useful
  • Add metadata to schema to define ref table names
  • Add first class notion of "datatype registry" to look up other tables to do joins on.
  • Figure out TS shenanigans to add de-ref'd fields for each ref'd field to datatype returns.
  • Nested deref
  • in-memory cache for getMany to reduce queries
  • real SQL joins? https://orm.drizzle.team/docs/joins (probs not)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions