Skip to content
Browse files

Add sections on reading / writing fields and observing models.

  • Loading branch information...
1 parent 1a0d8b6 commit d3902b029bfc0b0f409fb49cfec03c9ac877da9a @nathansobo committed May 17, 2012
Showing with 42 additions and 0 deletions.
  1. +42 −0 README.md
View
42 README.md
@@ -383,4 +383,46 @@ suggestToFollow = rankedAuthors.difference(followedAuthors)
## Working with Records
+### Reading / Writing Field Values
+
+Field accessor methods are available on your records for every column defined
+on their class.
+
+```coffeescript
+blog = Blog.find(11)
+console.log "#{blog.title()} by #{blog.user().fullName()}
+
+# just like in jQuery, call field accessors with an argument to assign values
+blog.title("New Title")
+blog.save() # more on saving later
+```
+
+### Observing Record Updates
+
+In addition to observing collections of objects via relations, you can also
+observe individual records with `onUpdate`.
+
+```coffeescript
+blog.onUpdate (changeset) ->
+ if changeset.title
+ oldTitle = changeset.title.oldValue
+ newTitle = changeset.title.newValue
+ console.log "The blog title changed from #{oldValue} to #{newValue}"
+```
+
+`onUpdate` returns a subscription object. Call `destroy` on it when you are no
+longer interested in updates.
+
+```coffeescript
+subscription = blog.onUpdate -> ...
+
+# I don't care about updates any more
+subscription.destroy()
+```
+
+### Synthetic Columns
+
+### Associations
+
+### CRUD Operations

0 comments on commit d3902b0

Please sign in to comment.
Something went wrong with that request. Please try again.