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

Attach connections and actions to models #28

Merged
merged 5 commits into from
Jun 5, 2024

Conversation

Brayden
Copy link
Member

@Brayden Brayden commented May 23, 2024

Purpose

Resolves #4

Tasks

  • BaseTable supports an attachConnection function for accessing query builder
  • Had a need to support multiple WHERE clauses in a query chain builder, support arrays
  • Store the original data object in each model for referencing the primary key values to base changes on
  • Change decorator support from getPrimaryKey(...) -> getPrimaryKeys(...)
  • The mapToClass function should automatically attachConnection to all models
  • Implement a pull() function in models for getting latest database values and updating model
  • Implement an update() function in models to automatically update their values in the database
  • Implement a delete() function in models to automatically delete the row entry from the database
  • Implement an insert() function in models to automatically create a new row entry with that classes values

Pending Questions:

  • Should the function name be sync() on a model where the model pulls latest values from database and sets its properties to it, or something more explicit to the directionality of the action such as .pull()

Verify

  • Need to verify query builder with single WHERE clause still operates as intended
  • Need to verify query builder with multiple WHERE clauses still operate as intended (pass in multiple .where({})
  • Need to verify query builder with multiple WHERE clauses still operate as intended (pass in array)
  • Test model can sync and self-update values to database values
  • Test model can update its values to the database
  • Test model can delete its row from the database
  • Test model can insert a new row into the database

Before

After

@Brayden Brayden self-assigned this May 23, 2024
@Brayden Brayden added enhancement New feature or request labels May 29, 2024
src/models/index.ts Outdated Show resolved Hide resolved
@Brayden Brayden marked this pull request as ready for review June 4, 2024 15:09
src/client.ts Outdated Show resolved Hide resolved
src/client.ts Outdated Show resolved Hide resolved
src/models/decorators.ts Outdated Show resolved Hide resolved
src/models/decorators.ts Show resolved Hide resolved
src/models/decorators.ts Outdated Show resolved Hide resolved
@Brayden Brayden merged commit 9421674 into main Jun 5, 2024
1 check passed
@Brayden Brayden deleted the bwilmoth/model-attach-connection branch June 5, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connect a connection to a class for quick actions
2 participants