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

Add Mixin Documentation #448

Closed
1 task
liquidgenius opened this issue Apr 24, 2021 · 2 comments
Closed
1 task

Add Mixin Documentation #448

liquidgenius opened this issue Apr 24, 2021 · 2 comments
Labels
enhancement A feature that exists, works as intended but needs to be improved

Comments

@liquidgenius
Copy link

liquidgenius commented Apr 24, 2021

Describe the feature as you'd like to see it
It appears documentation for Mixins under masoniteorm.scope is not yet written. Add best practice commonly used Mixins to documentation. Orator Orm provides a great example on this. https://orator-orm.com/docs/0.9/orm.html#soft-deleting

What do we currently have to do now?
Confirm a best practice model for SoftDeletesMixin, Timestamps... any others?

Additional context
Not a best practice model, but something to work off of to showcase capabilities.

"""Investigator Model."""
from masoniteorm.relationships import belongs_to
from masoniteorm.models import Model
from masoniteorm.scopes import scope, SoftDeletesMixin, TimeStampsMixin


class Investigator(Model, SoftDeletesMixin, TimeStampsMixin):
    """ Investigator model with parent-child hierarchy. """

    __guarded__ = []  # Pass-through, only for internal use, public-facing security implications

    __table__ = 'Investigators'  # not required, smart table association
    __timestamps__ = ['created_at', 'updated_at', 'deleted_at']  # includes deleted_at for Soft Deletions
    
    @belongs_to('id', 'id_base')
    def base(self):
        return Case

    @belongs_to('id', 'id_parent')
    def parent(self):
        return Case
    
    @belongs_to('id_ticketholder_org', 'id')
    def ticketholder(self):
        from app.models.Org import Org
        return Org

    @belongs_to('id_originator_org', 'id')
    def originator(self):
        from app.models.Org import Org
        return Org

    @belongs_to('id_platform', 'id')
    def platform(self):
        from app.models.Platform import Platform
        return Platform

    @belongs_to('id_status', 'id')
    def case_status(self):
        from app.models.CaseStatus import CaseStatus
        return CaseStatus

    @belongs_to('id_case_type', 'id')
    def case_type(self):
        from app.models.CaseType import CaseType
        return CaseType

    @scope
    def active(self, query):
        return query.where('active', 1)

    @scope
    def is_initialized(self, query):
        return query.where('is_initialized', 1)

    @scope
    def previously_seen(self, query):
        return query.where('previously_seen', 1)

    @scope
    def initial_data(self, query):
        return query.where('initial_data', 1)

    @scope
    def active(self, query, active_or_inactive):
        return query.where('active', active_or_inactive)

    @scope
    def max_winnables(self, query, max_winnables):
        return query.where_winnables(max_winnables)
@liquidgenius liquidgenius added the enhancement A feature that exists, works as intended but needs to be improved label Apr 24, 2021
@liquidgenius
Copy link
Author

Obviously, the model would need to be much simpler for the example. I will need help so as to insure the example fits with other examples in the docs.

@liquidgenius
Copy link
Author

Apparently, I missed this section on Soft Deleting https://orm.masoniteproject.com/models#soft-deleting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature that exists, works as intended but needs to be improved
Projects
None yet
Development

No branches or pull requests

1 participant