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

Feature request: add a remote:"never" option per save #138

Open
DaveSanders opened this issue Apr 21, 2015 · 4 comments
Open

Feature request: add a remote:"never" option per save #138

DaveSanders opened this issue Apr 21, 2015 · 4 comments
Milestone

Comments

@DaveSanders
Copy link

This is an edge case for me, but I have a case where a user model is used for login and that is sent up to the server. I'd like to not have the user's password in the localstorage after the login, so I can easily go in and do a:

user.save({password:null}, {remote:false})

Which is fine, but then there is a dirty user record sitting out there, that will never be saved to the server. It would be better if I could specify a local change with a remote:'never' or some other option and then have that change never go into the dirty (or destroyed) queues for later syncing.

(Now that I'm typing this, I think I just realized I need to do a custom parse maybe so that I can blank out that password before local save - so this might be a nonsensical case - but its an idea nonetheless.)

@nilbus
Copy link
Owner

nilbus commented Apr 27, 2015

We were discussing this here: #12 (comment)

I had also said this, which you have just shown me was an incorrect assumption:

I don't believe we need any mode that uses local storage does not mark records dirty.

Accounting for that, what do you think about having a storageMode option with these options? I'm open to suggestions on the option names. Do they make the behavior obvious?

storageMode: mode # one of: ['dual' (default), 'offline', 'remote-only', 'local-only']

@nilbus nilbus added this to the 2.0 milestone Apr 27, 2015
@DaveSanders
Copy link
Author

I think those work ok. I can't think of a reason why I would use remote-only right now, but it makes sense for completeness. I think the names work fine if their use is documented.

I'm not sure I understand what offline is for?

I'm a little bit confused - would these used in conjunction with the "remote: false" or as a replacement? If a replacement, then I agree this is a better system - providing the decision can be made broadly at the model AND at the individual record save.

Again, I'm dealing with a weird edge case, so I hate to pollute the pool with that. But if there are other uses then making sure to have a local-only for completeness would help my case.

@nilbus
Copy link
Owner

nilbus commented Apr 27, 2015

I will document the options regardless, but I hope to make the option names make sense without having to refer to documentation.

These would replace both the local and remote options. storageMode: 'offline' would be equivalent to how remote: false acts now: it skips the online step, makes the changes locally, and marks the records dirty. Does this table make it clear?

storageMode option online sync ($.ajax) localstorage update mark records dirty current equivalent
dual (default) ✅ if offline default
offline remote option false AND local attribute falsey
local-only remote option false AND local attribute truthy
remote-only remote attribute truthy

@DaveSanders
Copy link
Author

Yep, that makes sense!

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