From a560c41e537970ceea979c6f2b73a92fd4f91bcb Mon Sep 17 00:00:00 2001 From: pangratz Date: Mon, 4 Jan 2016 12:00:16 +0100 Subject: [PATCH] [DOC release] Replace deprecated `store.find` with `store.findRecord` (cherry picked from commit cf889b35a1f31d42fd54598ca9d5bc7753644a52) Conflicts: addon/-private/system/model/model.js addon/-private/system/store/finders.js --- addon/-private/system/coerce-id.js | 2 +- addon/-private/system/many-array.js | 2 +- addon/-private/system/model/internal-model.js | 2 +- addon/-private/system/model/model.js | 6 +++--- addon/-private/system/store.js | 4 ++-- addon/-private/system/store/finders.js | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addon/-private/system/coerce-id.js b/addon/-private/system/coerce-id.js index f325671ce05..59726f32e6d 100644 --- a/addon/-private/system/coerce-id.js +++ b/addon/-private/system/coerce-id.js @@ -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 diff --git a/addon/-private/system/many-array.js b/addon/-private/system/many-array.js index 16640a4dd5b..fedb2b7917c 100644 --- a/addon/-private/system/many-array.js +++ b/addon/-private/system/many-array.js @@ -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); diff --git a/addon/-private/system/model/internal-model.js b/addon/-private/system/model/internal-model.js index 679e1067720..aafedbd814d 100644 --- a/addon/-private/system/model/internal-model.js +++ b/addon/-private/system/model/internal-model.js @@ -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. diff --git a/addon/-private/system/model/model.js b/addon/-private/system/model/model.js index 078094727da..208af60c976 100644 --- a/addon/-private/system/model/model.js +++ b/addon/-private/system/model/model.js @@ -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 }); ``` @@ -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 @@ -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' }); ``` diff --git a/addon/-private/system/store.js b/addon/-private/system/store.js index 6f6cba1d3bd..670bb5642af 100644 --- a/addon/-private/system/store.js +++ b/addon/-private/system/store.js @@ -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 }); ``` diff --git a/addon/-private/system/store/finders.js b/addon/-private/system/store/finders.js index 494c6802f3a..221152f0699 100644 --- a/addon/-private/system/store/finders.js +++ b/addon/-private/system/store/finders.js @@ -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));