Created
June 14, 2015 05:17
-
-
Save ralyodio/9be6b15ad846b7a2cc10 to your computer and use it in GitHub Desktop.
thinky hasAndBelongsToMany
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ctrl.post = function *(next){ | |
var data = this.request.body; | |
var tagIds = data.tags.map(tag => { | |
return tag.id; | |
}); | |
delete data.tags; | |
var post = new Post(data); | |
post.tags = tagIds; | |
var newPost = yield post.saveAll(); //save joins | |
var result = yield Post.get(newPost.id).getJoin({ tags: true }); | |
this.body = result; | |
yield next; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment