Skip to content
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

Update model locally after save #49

Open
cristiandouce opened this issue Jul 23, 2013 · 1 comment
Open

Update model locally after save #49

cristiandouce opened this issue Jul 23, 2013 · 1 comment

Comments

@cristiandouce
Copy link
Member

A use case:

var Post = model('Post')
  .attr('id')
  .attr('title')
  .attr('slug')
  .attr('content')
  .attr('author');

var post = new Post({
  title: "My new post",
  content: "My awesome post content"
});

post.save(function(err, res) {
  post.slug() // undefined
  res.body.slug // "my-new-post"

  post.author() // undefined
  res.body.author // "Cristian Douce"
});

It would be nice to have this kind of sync between model instance and server response object. Now I have to manually set an onsave callback and update model manually with the con of having my model dirty after that. Not nice :(

@yocontra
Copy link

yocontra commented Feb 6, 2014

👍

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

No branches or pull requests

2 participants