-
Notifications
You must be signed in to change notification settings - Fork 12
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
StakeRequest model (with a help of sequelize) #73
StakeRequest model (with a help of sequelize) #73
Conversation
- Enables syncing all database tables once. - Adds common configuration settings for all tables. - Defines stake request number fields as unsigned integer. - Adds deferred sync functionality for table creation and table operations.
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.
This looks very clean 👍
Questions:
-
Why do we need
StakeRequestAttributes
? Is it that any class that implement theStakeRequestAttributes
interface can be passed in thebuild
andcreate
params? -
What
StakeRequestRepository.build
does? -
What do you think if we do the following?
StakeRequestRepository
can extendsModel
StakeRequestModel
can be a simple class that has all the properties (may be some functions to implement business logic). Implements/confirms to theStakeRequestAttributes
interface.StakeRequestModel
can be passed as params inStakeRequestRepository.build
andStakeRequestRepository.create
StakeRequestModel
is returned fromStakeRequestRepository.get
function.
In this way there is clear separation of Model objects(related to facilitator) and Repository (sequelize model objects)
- Hides sequelize from Database public interface. - Updates table and model names for StakeRequestModel. - Removes StakeRequestRepository::build interface for now. - Improves StakeRequestRepository::create unit test.
Yes. StakeRequestAttributers is an interface for an input to create StakeRequest object.
In the current design, StakeRequestModel is a sequelize model, which in my understanding represents two things: a database schema model, its Currently, for abstracting away from underlying database representation there are StakeRequestAttributes, StakeRequest and StakeRequestRepository classes. I've made some changes after your comment, please, have a look and we could discuss this point one more time. Thx! |
Started reviewing 🎸 🚗 |
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.
Really nice work with sequelize integration 🚀 💯
Liked the classes segregation.
Added few suggestions:
-
Database class can create and return singleton sequelize instance. It makes sure there are not too many sequelize db instances.
-
Migrations can be used for creating tables.
-
I feel 🤔 we shouldn't import/load all repositories at once for memory footprint and maintenance. As respositries increase this will not be maintainable . Currently Database class loads all the repositories. We can import/load only those repositories which are needed in a service/process.
Removes an empty StakeRequestRepository::constructor tests file. Updates unit tests accordingly.
Reviewing 🚋 |
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.
LGTM 💯 👍
I have added a few comments.
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.
Overall looks good to me 🥇
Added few minor comments on tests.
- Improves documentation for StakeRequestRepository. - Enhances error message for StakeRequestRepository::create.
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.
LGTM
Implements stake request model classes.
StakeRequestAttributes
: Represents an interface for an input to createStakeRequest
objects inStakeRequestRepository
.StakeRequest
: Represents a stake request object to be used throughout facilitator.StakeRequestModel
: Represents aStakeRequest
database model. Allows to initialize stake request database table's schema and in addition represents a raw in that table.StakeRequestRepository
: Allows to create and retrieve stake request object. A class should be an interface for other classes in facilitator to interact with stake request model.Database
: Creates, initializes and gives an access to different models throughout facilitator.Fixes: #53