Skip to content

how to use EAV model with normal entity? #43

@videni

Description

@videni

I am using EAV with normal entities.

Use case

user has many roles, roles can belong to many users. Let's assume User is an EAV model, but Role is a normal entity.

Question 1 : how to design the User EAV model.

sidus_eav_model:
    families:
        Project:
            attributeAsLabel: username
            attributes:
                username:
                    required: true
                    type: string
               roles:
                    type: integer
                    collection: true
<entity name="Acme\Component\User\Model\Role" table="acme_role">
        <id name="id" type="integer">
            <generator strategy="AUTO"/>
        </id>
        <field name="role" type="string" unique="true" length="30" nullable="false"/>
        <field name="label" type="string" length="30"/>
        <field name="description" type="text" nullable="true"/>
    </entity>

Question 2: What is the effecient way to get a list of users with associated roles?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions