joist-orm / joist-orm/joist-orm

Teach createOrUpdatePartial to use non-id fields

Open
#825 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
385
Forks
26
Avg merge
8h 55m
Merged PRs (30d)
42

Description

It'd be neat if the `upsert`-capabilities of `createOrUpdatePartial` could use unique columns like `code` to find an existing row.

Also maybe "unique per parent", i.e. a `Product` parent with `ProductDimension` children, but there should be only one `ProductDimension` for a given `type` for each `Product`.

With the combination of `config.addRule(uniquePerParentAnd("product", "type"))`, we could take `saveProduct({ id: "pr:1", dimensions: [{ type: ..., value: ... }] })` and update existing dimensions-of-that-type.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.