SupermodelBackbonejs 的數(shù)據(jù)模型層
Supermodel 是 Backbonejs 的數(shù)據(jù)模型層。
示例代碼:
Post.has().many('comments', {
collection: Comments,
inverse: 'post'
});
Comment.has().one('post', {
model: Post,
inverse: 'comments'
});
var post = Post.create({
id: 1,
comments: [{id: 2}, {id: 3}, {id: 4}]
});
post.comments().length; // 3
var comment = Comment.create({id: 5, post_id: 1});
post.comments().length; // 4
comment.post() === post; // true :D評論
圖片
表情
