# Is there an event when update parts of a model from backend?

**URL:** <https://discuss.emberjs.com/t/is-there-an-event-when-update-parts-of-a-model-from-backend/13509>\
**Category:** Ember Data\
**Created:** [August 22, 2017, 11:39am UTC](https://discuss.emberjs.com/t/is-there-an-event-when-update-parts-of-a-model-from-backend/13509 "2017-08-22T11:39:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Myrdhin](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/myrdhin/32/16107_2.png) [@Myrdhin](https://discuss.emberjs.com/u/Myrdhin)\
**Post date:** [August 22, 2017, 11:39am UTC](https://discuss.emberjs.com/t/is-there-an-event-when-update-parts-of-a-model-from-backend/13509/1 "2017-08-22T11:39:07Z")

</div>

We have the following model:

```javascript
// app/models/user.js
import Ember from 'ember';
import DS from 'ember-data';

export default DS.model.extend({
  login : DS.attr('string'),
  language : DS.attr('string'),
  homepage : DS.attr('string'),
  firstname: DS.attr('string'),
  lastname : DS.attr('string')
})

```

We have a login route where a user is loaded (with a `this.get('store').queryRecord('user', ...)`) from the backend. Only `login`, `language` and `homepage` attributes are loaded. So we have a user instance with these attributes defined in the store and other are `undefined`.

Another route display a user list where this previous user is displayed too. We use `this.get('store').query('user', queryparams)` to load this list. Only `firstname` and `lastname` of each user are loaded so the previous user instance (_loaded in login route_) is updated in the store.

We need to to know when this update occurs : is there an event about this? Thanks for your help,

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [August 22, 2017, 2:09pm UTC](https://discuss.emberjs.com/t/is-there-an-event-when-update-parts-of-a-model-from-backend/13509/2 "2017-08-22T14:09:20Z")

</div>

DS.Model has a ‘didUpdate’ event so you could subscribe to that (pretty sure you can do it on just the one record you’re concerned with, like `theRecord.on('didUpdate', function()....)`). Alternatively you could put a `.then(...)` on the query in your model hook because when that query resolves is when the record will be updated. Depending on your needs that may not be what you want though, I’m not sure offhand if the record is actually updated before or after the `.then` function would be executed. .

---

<div class="post-metadata">

**Author:** ![Myrdhin](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/myrdhin/32/16107_2.png) [@Myrdhin](https://discuss.emberjs.com/u/Myrdhin)\
**Post date:** [August 22, 2017, 4:17pm UTC](https://discuss.emberjs.com/t/is-there-an-event-when-update-parts-of-a-model-from-backend/13509/3 "2017-08-22T16:17:24Z")

</div>

Thank you for your proposal. But the ‘didUpdate’ event is fired after saving/sending the record to backend. In my case, only the record in the store is updated.

Yes i could use a `.then` but my example here is simple : I would like something more generic because i have a lot of models that works like this 😟
