# Partial data models

**URL:** <https://discuss.emberjs.com/t/partial-data-models/16714>\
**Category:** Ember Data\
**Created:** [June 25, 2019, 11:59am UTC](https://discuss.emberjs.com/t/partial-data-models/16714 "2019-06-25T11:59:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![naomak](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/naomak/32/16465_2.png) [@naomak](https://discuss.emberjs.com/u/naomak)\
**Post date:** [June 25, 2019, 11:59am UTC](https://discuss.emberjs.com/t/partial-data-models/16714/1 "2019-06-25T11:59:13Z")

</div>

Is there any “state of art” or tips & tricks for how to use ember-data and in the same time take advantage of having partial data models (having simple model for list as a part of complete model for detail).

Is the best way for this case to drop ember-data?

Do the bigger companies using their own private solutions?

A found [https://github.com/BookingSync/ember-data-partial-model](https://github.com/BookingSync/ember-data-partial-model), but last commit is form 2016.

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [June 25, 2019, 12:40pm UTC](https://discuss.emberjs.com/t/partial-data-models/16714/2 "2019-06-25T12:40:17Z")

</div>

My preference is to be explicit about it and have two models, with a relationship between them if you need to use the simpler one to load the full one.

Like `PostSummary` vs `Post`, or `Post` vs `PostDetail`.

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [June 25, 2019, 12:42pm UTC](https://discuss.emberjs.com/t/partial-data-models/16714/3 "2019-06-25T12:42:37Z")

</div>

To clarify, this doesn’t necessarily mean duplicating fields in two models.

You can have all the basic fields in `Post` and only the extended fields in `PostDetail`. When you want all of them, you load the Post while including (in the sense of JSON:API `included`) `PostDetail`.

---

<div class="post-metadata">

**Author:** ![naomak](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/naomak/32/16465_2.png) [@naomak](https://discuss.emberjs.com/u/naomak)\
**Post date:** [June 25, 2019, 2:01pm UTC](https://discuss.emberjs.com/t/partial-data-models/16714/4 "2019-06-25T14:01:35Z")

</div>

Thank you for your opinion. And when you create or update, do you update two separete models with two endpoints, or another model like PostForm and let backend handle processing?

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [June 25, 2019, 2:38pm UTC](https://discuss.emberjs.com/t/partial-data-models/16714/5 "2019-06-25T14:38:28Z")

</div>

It depends on how badly you need atomic updates. If it’s not a big deal, updating the two models separately works fine. And it has the benefit of being explicit from ember-data’s perspective.

If you do need atomic updates, then you do want a smarter endpoint on the server that can take the whole update at once. If you do that, you need to make sure the response that comes back updates both models ember data’s cache (if the response uses JSON:API `included`with both the real models that should do it).

---

<div class="post-metadata">

**Author:** ![runspired](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/runspired/32/18654_2.png) [@runspired](https://discuss.emberjs.com/u/runspired)\
**Post date:** [June 27, 2019, 6:25pm UTC](https://discuss.emberjs.com/t/partial-data-models/16714/6 "2019-06-27T18:25:51Z")

</div>

One of the motivations behind ember-m3 which is alternative model layer for ember-data is support for partial data models.

---

<div class="post-metadata">

**Author:** ![naomak](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/naomak/32/16465_2.png) [@naomak](https://discuss.emberjs.com/u/naomak)\
**Post date:** [July 4, 2019, 10:52am UTC](https://discuss.emberjs.com/t/partial-data-models/16714/7 "2019-07-04T10:52:16Z")

</div>

Thanks for tip @runspired!
