Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Unable to use UUID's as permanent ids #117

Closed
almilli opened this issue Jul 6, 2014 · 3 comments
Closed

Unable to use UUID's as permanent ids #117

almilli opened this issue Jul 6, 2014 · 3 comments
Assignees
Milestone

Comments

@almilli
Copy link
Contributor

almilli commented Jul 6, 2014

DualStorage uses UUIDs as the temporary id generator. And detects the id being a temporary id as one that looks like a UUID. This means that it's impossible to use DualStorage out of the box if the server also uses UUIDs as the permanent id. I can see this being a very common use case. What ends up happening is that DualStorage never issues "remote" server commands when inserting/updating/deleting items. You should change it to use temporary ids that are something more unique instead of using a standard for real ids.

In order to get this to work, I had to override the temporary id generation and check. I just prepended a "t" to a UUID so it was a different length than a normal UUID.

    Backbone.Model.prototype.hasTempId = function() {
         return _.isString(this.id) && this.id.length === 37;
    };
    window.Store.prototype.generateId = function() {
         return "t" + uuid.v4();
    }
@nilbus
Copy link
Owner

nilbus commented Jul 6, 2014

I like your solution and agree that this is a problem. We cannot prepend a
t and have it be backward compatible, but it will be backward compatible if
the length is still 36 characters, like if the first character was a T
rather than a hex character. If you'd like to see this in the official
repo, go ahead and make a pull request. If you run make and update
CHANGES.md, then I can accept it directly. Thanks!

@nilbus nilbus self-assigned this Jul 6, 2014
@nilbus nilbus added this to the 2.0 milestone Jul 7, 2014
@nilbus nilbus modified the milestone: 2.0 Jul 7, 2014
@almilli
Copy link
Contributor Author

almilli commented Jul 8, 2014

Ok, I created a pull request #118

@nilbus
Copy link
Owner

nilbus commented Feb 16, 2015

Released in v1.4.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants