Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #808 from JasonKriss/map-docs

Fix docs for Adapter's map API
  • Loading branch information...
commit 309ec2bd639e0eb45032cc67051d5be71e511269 2 parents 1032a75 + 6d52a89
@trek trek authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.