Permalink
Browse files

Fix docs for Adapter's map API

  • Loading branch information...
1 parent 1032a75 commit 6d52a89c5696cb691836208e7a9d8eacf10ed61d @jasonkriss jasonkriss committed Mar 14, 2013
Showing with 15 additions and 6 deletions.
  1. +1 −1 packages/ember-data/lib/system/mixins/mappable.js
  2. +14 −5 packages/ember-data/lib/system/serializer.js
View
2 packages/ember-data/lib/system/mixins/mappable.js
@@ -9,7 +9,7 @@ var classify = Ember.String.classify, get = Ember.get;
For example, the DS.Adapter class can behave like a map, with
more semantic API, via the `map` API:
- DS.Adapter.map('App.Person', { firstName: { keyName: 'FIRST' } });
+ DS.Adapter.map('App.Person', { firstName: { key: 'FIRST' } });
Class configuration via a map-like API has a few common requirements
that differentiate it from the standard Ember.Map implementation.
View
19 packages/ember-data/lib/system/serializer.js
@@ -62,20 +62,29 @@ function mustImplement(name) {
by implementing `keyForAttributeName`:
```javascript
- keyForAttributeName: function(type, name) {
- return name.underscore.toUpperCase();
- }
+ keyForAttributeName: function(type, name) {
+ return name.underscore.toUpperCase();
+ }
```
If your attribute names are not predictable, you can re-map them
- one-by-one using the `map` API:
+ one-by-one using the adapter's `map` API:
```javascript
- App.Person.map('App.Person', {
+ App.Adapter.map('App.Person', {
firstName: { key: '*API_USER_FIRST_NAME*' }
});
```
+ This API will also work for relationships and primary keys. For
+ example:
+
+ ```javascript
+ App.Adapter.map('App.Person', {
+ primaryKey: '_id'
+ });
+ ```
+
## Serialization
During the serialization process, a record or records are converted

0 comments on commit 6d52a89

Please sign in to comment.