Permalink
Browse files

Merge branch 'master' of github.com:mde/geddy

  • Loading branch information...
2 parents bc02170 + 3c91612 commit c0dbf0fa0e0d76e080875ea7870d45eb2801b467 @larzconwell larzconwell committed Oct 15, 2012
Showing with 118 additions and 0 deletions.
  1. +63 −0 docs/4-models.md
  2. +55 −0 docs/7-sessions.md
View
@@ -286,6 +286,69 @@ user.updateProperties({
// updates the login property and validates it
```
+#### .add
+`.add{target_model_name}( instance )`
+
+If a model has a hasMany relationship established with another model, you can use this method to add instaces of one model to it’s “parent” model.
+
+##### target_model_name
+- The name of the model you’d like to add
+
+##### instance
+- `instace [modelInstance]`: The instance to add
+
+##### example
+```
+var user = geddy.model.User.create(userParams);
+var post = geddy.model.Post.create(postParams);
+user.addPost(post);
+```
+
+#### .set
+`.set{target_model_name}( instance )`
+
+If a model has a hasOne relationship established with another model, you can use this method to add an instace of one model to it’s “parent” model.
+
+##### target_model_name
+- The name of the model you’d like to set
+
+##### instance
+- `instace [modelInstance]`: The instance to set
+
+##### example
+```
+var user = geddy.model.User.create(userParams);
+var account = geddy.model.Account.create(accountParams);
+user.setAccount(account);
+```
+
+#### .get
+`.get{target_model_name}( fn )`
+
+If a model has a hasOne relationship established with another model, you can use this method to add an instace of one model to it’s “parent” model.
+
+##### target_model_name
+- `hasMany`: the plural name of the model you’d like to get a collection of
+- `hasOne`: the singular name of the model you like to get an instance of
+
+##### fn
+- `fn [function]`: The function to call once the models are retrieved.
+
+##### example
+```
+var user = geddy.model.User.create(params);
+
+// hasOne
+user.getAccount(function (err, account) {
+ // do stuff with the user’s account
+});
+
+// hasMany
+user.getPosts(function (err, posts) {
+ // do stuff with the user’s posts
+});
+```
+
* * *
#### static
View
@@ -0,0 +1,55 @@
+Sessions are used to keep track of current connections to the server.
+
+#### .get
+`get( key )`
+
+Gets a key from the current session.
+
+##### key
+- `key [string]`: the key to return the value of
+
+##### example
+```
+var user = this.session.get(‘user’);
+```
+
+#### .set
+`set( key, value )`
+
+Saves a value to the current session as a key
+
+##### key
+- `key [string]`: the key to set on the session
+
+##### value
+- `value [object]`: the value to save to the session
+
+##### example
+```
+this.session.set(‘user’, user);
+```
+
+#### .unset
+`unset( key )`
+
+Removes a key and value from the current session
+
+##### key
+- `key [string]`: the key to remove
+
+##### example
+```
+this.session.unset(‘user’);
+```
+
+#### .isExpired
+```
+isExpired()
+```
+
+Returns true if the current session has expired
+
+##### example
+```
+this.session.isExpired
+```

0 comments on commit c0dbf0f

Please sign in to comment.