Created
September 21, 2020 14:57
-
-
Save Sukonnik-Illia/7de05f68735b163d89abfd7e59d3b794 to your computer and use it in GitHub Desktop.
builder with or without db saving and relational objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# with relational objects and with sawing to database | |
( | |
ChargeBuilder(database) | |
.with_customer(CustomerBuilder(database).build()) | |
.with_delivery_date(DeliveryDateBuilder(database).build()) | |
.build() | |
) | |
# simple builder | |
customer = CustomerBuilder().build() | |
database.save_customer(customer) | |
delivery_date = DeliveryDateBuilder().build() | |
database.save_delivery_date(delivery_date) | |
charge = ( | |
ChargeBuilder() | |
.with_delivery_date(delivery_date) | |
.with_customer(customer) | |
) | |
database.save_charge(charge) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment