Skip to content

Update model locally after save #49

@cristiandouce

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

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