Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-design the "Relation" class #130

Merged
merged 4 commits into from
Oct 14, 2021
Merged

Re-design the "Relation" class #130

merged 4 commits into from
Oct 14, 2021

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Oct 13, 2021

Breaking changes

  • Relational properties can no longer be updated using a compatible plain object. Only actual relations can be used to update relations.

Changes

  • The Relation class now has distinct methods to initialize the relation and apply the property proxy.
  • Scopes all the info needed for a relation in its class.
  • Introduces the concepts of "source" (an entity that has a relation) and "target" (an entity that is being referenced).
  • unique is not called a relation attribute.
  • Moves unique relational properties tests to the respective relation kind tests (no longer a separate unique.test.ts).

Bug fixes

  • Fixes an issue that prevented an update of a property if it wasn't specified when the entity was created.
  • Fixes an issue that broke the querying by an entity's property if that property has no value.
db.user.create({ id: 'abc-123' })

// The following query would throw.
db.user.findFirst({ where: { anotherProperty: { equals: 'value' } } })
  • Fixes an issue that would throw an exception when validating a unique relational value if that value is currently assigned to the entity that's being operated on (must exclude the current entity from the validation query).

GitHub

Roadmap

  • Cover the Relation class with unit tests.
  • Review the new Relation class method names: apply and resolveWith.
  • Resolve all @fixme comments.

@kettanaito kettanaito marked this pull request as draft October 13, 2021 14:27
@kettanaito kettanaito changed the title Re-design the "Relation" Re-design the "Relation" class Oct 13, 2021
@kettanaito kettanaito marked this pull request as ready for review October 14, 2021 10:36
@kettanaito kettanaito merged commit 024eefb into master Oct 14, 2021
@kettanaito kettanaito deleted the 127-relation-redesign branch October 14, 2021 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-design relational properties
1 participant