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
Option to use client-side generated UUIDs #451
Conversation
This is one of those I don't have a direct need for, but seems like it would be useful. Since one of the appeals of spine is approachable source code I think documenting this well is important if we want to include it as it would have potential to confuse. As it is I think the id vs cid stuff can get a little perplexing for people new to spine or client side MVC in general. |
Agreed. Not only that, but it seems to me that the whole idea of waiting for I wonder if it would be practical to add |
I really like the idea of a being able to plugin different modules/code to override the default id creation. One question on this, does this end up breaking the If we are setting up the |
I haven't noticed any changes. new Client().isNew() # true
new Client().save().isNew() # false |
Now that I think about it, that makes sense, as long as its not stored in the |
Think we could bring this in. Mostly could use content of pull request description for documentation it looks like. |
Option to use client-side generated UUIDs
If a model has been given a
@uuid()
method, it'll be used in the constructor to generate@cid
, and also set@id
to the same value right away (without waiting for@save()
).This allows records to be created by
relation.coffee
without needing to wait for server-generated IDs to associate them. I use this for scenarios where a controller needs to build a few (unsaved) related records which it may or may not send to the server depending on user actions.Example usage with node-uuid:
Here's what it can do:
Everything works as usual if the
@uuid()
method is missing.