-
Notifications
You must be signed in to change notification settings - Fork 36
Unique attributes #60
Description
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.