JSFiddle - React, Tailwind, and code Playground

by abernier

HTML

<script src="https://raw.github.com/maccman/spine/master/lib/spine.js"></script>
<script src="https://raw.github.com/abernier/spine/master/lib/relation.js"></script>

CoffeeScript

class Album extends Spine.Model
  @configure 'Album', 'name'
  @hasMany 'photos', 'Photo'
window.Album = Album

class Photo extends Spine.Model
  @configure 'Photo', 'name'
  @belongsTo 'album', 'Album'
window.Photo = Photo

Photo.bind 'refresh', (photos) ->
  console.log photos
  
myAlbum = Album.create(name: 'My album')

myAlbum.photos().refresh([
  {name: 'photo1'}
  {name: 'photo2'}
]);