Skip to content
This repository was archived by the owner on Apr 22, 2021. It is now read-only.

Unique attributes #60

@TheBox193

Description

@TheBox193

I've been really enjoying the power and elegance of supermodel, thanks so much!

I have a case where I can retrieve models from my backend via an additional unique attribute other than id - in my case username. In the cases where I .create({id: 10}) we naturally check for an existing model. However when .create({username: 'TheBox193'}) there is no id to match and thus a new model is created. I could programmatically change the idAttribute temporarily, however that seems it might be less than ideal.

Since models (for any applications) could have several unique attributes (id, username, email, etc.) would it make sense to match models based off of additional attributes to reduce duplicates? My thought would be to add a uniqueAttributes on the model that would define additional attributes a model could be matched by for the application.

I could write a draft of this up if it would make sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions