Supermodel 是 Backbonejs 的数据模型层。
示例代码:
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