0
votes

Before I get into the question, I should point out that I do not want to use the find operation to retrieve a record from the data store, I am attempting to access only the local storage without hitting the backend.

Okay, with that out of the way, I was looking at the ember docs which states the following: /** Update existing records in the store. Unlike push, update will merge the new data properties with the existing properties. This makes it safe to use with a subset of record attributes. This method expects normalized data.

update is useful if your app broadcasts partial updates to
records.

App.Person = DS.Model.extend({
  firstName: DS.attr('string'),
  lastName: DS.attr('string')
});

store.get('person', 1).then(function(tom) {
  tom.get('firstName'); // Tom
  tom.get('lastName'); // Dale

  var updateEvent = {id: 1, firstName: "TomHuda"};
  store.update('person', updateEvent);

  tom.get('firstName'); // TomHuda
  tom.get('lastName'); // Dale
});

Now..my issue is when I try to do this:

store.get('person', 1).then(function(tom)

get is returning undefined even though when I use Ember Inspector, I can see the record inside the data store.

The happens for any objects I attempt to query in the store.

How do you use the store.get api?

1
In order to use store.update with this above example, it only works when updating records that already exist in the store and not records that have been pushed onto the store without a commit. I will clean up the question to refer to the issue related to get. - joker1979

1 Answers

1
votes

The store's get method is inherited from Ember.Object, meaning that it has absolutely nothing to do with records. You're looking for the store's getById method.