-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Remove Database from Model #98
Remove Database from Model #98
Conversation
import { createStore, fillState, assertState } from 'test/Helpers' | ||
import { Model, Attr, Str } from '@/index' | ||
|
||
describe('feature/model/deletes_delete', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following method is deleted so we no longer need these tests.
import { createStore, fillState, assertState } from 'test/Helpers' | ||
import { Model, Attr, Str } from '@/index' | ||
|
||
describe('feature/model/deletes_delete_composite_key', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following method is deleted so we no longer need these tests.
it('throws when accessing the database but it is not injected', () => { | ||
expect(() => new User().$database()).toThrow() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The database is no longer injected into the model so we no longer need this test.
@@ -22,7 +22,6 @@ describe('unit/repository/Repository', () => { | |||
const user = store.$repo(User).make() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing expectations of injected databases into the Model
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWESOOOME! Thanks a lot. Let's merge this after we make a new release for MorphOne and withAll
and withAllRecursive
methods. Since this is a breaking change, I think it's better to push plain new feature release first 👍
Thanks!!!!! 🙌 🎉 |
Type of PR:
Breaking changes:
The following attributes have been removed from the
Model
:_database
The following methods have been removed from the
Model
:$database
$setDatabase
$query
$delete
$deleteByKeyName
$deleteByCompositeKeyName
Details
Purpose
The purpose of this PR is to remove
Database
access from theModel
in order to simplify theModel
and enforce a repository pattern when using the ORM. This means that we will stop relying on theModel
to retrieve anotherModel
and instead use theRepository
orDatabase
to fetch any other models.Changes
Database
fromModel
& any other associated methods