Skip to content

Update model locally after save #49

Description

@cristiandouce

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 :(

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions