# Lazy Loading Ember-Data Queries

**URL:** https://discuss.emberjs.com/t/lazy-loading-ember-data-queries/10269
**Category:** Ember Data
**Created:** [March 25, 2016, 2:23am UTC](https://discuss.emberjs.com/t/lazy-loading-ember-data-queries/10269 "2016-03-25T02:23:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![anlumo](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@anlumo](https://discuss.emberjs.com/u/anlumo)
#### Post date: [March 25, 2016, 2:23am UTC](https://discuss.emberjs.com/t/lazy-loading-ember-data-queries/10269/1 "2016-03-25T02:23:11Z")

</div>

I’m trying to write an ember-data adapter for a custom API backend. It allows full-text search using a query, returning records from the store.

I implemented `query(store, type, query)` in my adapter, and it works fine, but only when I return the full model when resolving the promise. This might be thousands of objects, and I don’t want to display them all at once anyways. Is there a way to return incomplete objects here that get queried via `findRecord` once they’re actually needed?

I can return an array of `{id:"..."}` objects from there, but they just have all attributes set to undefined and are never fetched from the server. Their `isLoaded` flag is incorrect.

Manually calling `reload()` on all objects returned from that query does set the attributes correctly, but that’s not the point of using ember-data in the first place.

How can I modify the `isLoaded` flag for this?

---

<div class="post-metadata">

### Author: ![anlumo](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@anlumo](https://discuss.emberjs.com/u/anlumo)
#### Post date: [March 31, 2016, 6:24pm UTC](https://discuss.emberjs.com/t/lazy-loading-ember-data-queries/10269/2 "2016-03-31T18:24:35Z")

</div>

To answer my own question, I found a nice workaround:

I created an intermediary model class that only contains an id and a belongsTo property to the real object (both using the same id). This way, the returned object is fully loaded, but once you try to access the belongsTo property, it is loaded asynchronously from the server. This is exactly what I want.
