Skip to content

Commit

Permalink
[DOC release] Replace deprecated store.find with store.findRecord
Browse files Browse the repository at this point in the history
(cherry picked from commit cf889b3)

Conflicts:
	addon/-private/system/model/model.js
	addon/-private/system/store/finders.js
  • Loading branch information
pangratz authored and bmac committed Jan 11, 2016
1 parent dad2970 commit a560c41
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion addon/-private/system/coerce-id.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Used by the store to normalize IDs entering the store. Despite the fact
// that developers may provide IDs as numbers (e.g., `store.find(Person, 1)`),
// that developers may provide IDs as numbers (e.g., `store.findRecord('person', 1)`),
// it is important that internally we use strings, since IDs may be serialized
// and lose type information. For example, Ember's router may put a record's
// ID into the URL, and if we later try to deserialize that URL and find the
Expand Down
2 changes: 1 addition & 1 deletion addon/-private/system/many-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default Ember.Object.extend(Ember.MutableArray, Ember.Evented, {
Example
```javascript
store.find('inbox', 1).then(function(inbox) {
store.findRecord('inbox', 1).then(function(inbox) {
inbox.get('messages').then(function(messages) {
messages.forEach(function(message) {
message.set('isRead', true);
Expand Down
2 changes: 1 addition & 1 deletion addon/-private/system/model/internal-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ InternalModel.prototype = {
came back from the server, except the user obtained them out of band and is informing
the store of their existence. The most common use case is for supporting client side
nested URLs, such as `/posts/1/comments/2` so the user can do
`store.find('comment', 2, {post:1})` without having to fetch the post.
`store.findRecord('comment', 2, { preload: { post: 1 } })` without having to fetch the post.
Preloaded data can be attributes and relationships passed in either as IDs or as actual
models.
Expand Down
6 changes: 3 additions & 3 deletions addon/-private/system/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var Model = Ember.Object.extend(Ember.Evented, {
var record = store.createRecord('model');
record.get('isLoaded'); // true
store.find('model', 1).then(function(model) {
store.findRecord('model', 1).then(function(model) {
model.get('isLoaded'); // true
});
```
Expand All @@ -104,7 +104,7 @@ var Model = Ember.Object.extend(Ember.Evented, {
var record = store.createRecord('model');
record.get('hasDirtyAttributes'); // true
store.find('model', 1).then(function(model) {
store.findRecord('model', 1).then(function(model) {
model.get('hasDirtyAttributes'); // false
model.set('foo', 'some value');
model.get('hasDirtyAttributes'); // true
Expand Down Expand Up @@ -283,7 +283,7 @@ var Model = Ember.Object.extend(Ember.Evented, {
var record = store.createRecord('model');
record.get('id'); // null
store.find('model', 1).then(function(model) {
store.findRecord('model', 1).then(function(model) {
model.get('id'); // '1'
});
```
Expand Down
4 changes: 2 additions & 2 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1209,14 +1209,14 @@ Store = Service.extend({

/**
This method returns if a certain record is already loaded
in the store. Use this function to know beforehand if a find()
in the store. Use this function to know beforehand if a findRecord()
will result in a request or that it will be a cache hit.
Example
```javascript
store.recordIsLoaded('post', 1); // false
store.find('post', 1).then(function() {
store.findRecord('post', 1).then(function() {
store.recordIsLoaded('post', 1); // true
});
```
Expand Down
2 changes: 1 addition & 1 deletion addon/-private/system/store/finders.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function _find(adapter, store, typeClass, id, internalModel, options) {
var snapshot = internalModel.createSnapshot(options);
var promise = adapter.findRecord(store, typeClass, id, snapshot);
var serializer = serializerForAdapter(store, adapter, internalModel.type.modelName);
var label = "DS: Handle Adapter#find of " + typeClass + " with id: " + id;
var label = "DS: Handle Adapter#findRecord of " + typeClass + " with id: " + id;

promise = Promise.resolve(promise, label);
promise = _guard(promise, _bind(_objectIsAlive, store));
Expand Down

0 comments on commit a560c41

Please sign in to comment.