# Add DS.Store base delegate method to the adapter

**URL:** <https://discuss.emberjs.com/t/add-ds-store-base-delegate-method-to-the-adapter/9181>\
**Category:** Ember Data\
**Created:** [November 25, 2015, 4:48pm UTC](https://discuss.emberjs.com/t/add-ds-store-base-delegate-method-to-the-adapter/9181 "2015-11-25T16:48:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![teckays](https://avatars.discourse-cdn.com/v4/letter/t/258eb7/32.png) [@teckays](https://discuss.emberjs.com/u/teckays)\
**Post date:** [November 25, 2015, 4:48pm UTC](https://discuss.emberjs.com/t/add-ds-store-base-delegate-method-to-the-adapter/9181/1 "2015-11-25T16:48:57Z")

</div>

I’m wondering if I need to extend the `DS.Store` class in order to add a query method like `this.store.search()` for example, would it be possible on the current version?

This need comes from the fact that I have a `JSONAPIAdapter`-like backend API but with some minor changes. For example I have a custom route to perform searches on the model `/{model}/search` and none of the existing methods, `findAll()`, `query()` and others help me achieve this functionality without overriding some of them which is not something I really like.

The build-in `this.store.query()` method works great if I want to query on a specific model field, but for `search()` I’m using a `text` parameter which looks over multiple model fields to find a match.

The best approach in my opinion would be to extend the `DS.Store` class and add a `this.store.search()` method for example that would allow me to automatically search for records on any model.

---

<div class="post-metadata">

**Author:** ![planetexpress69](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/planetexpress69/32/11530_2.png) [@planetexpress69](https://discuss.emberjs.com/u/planetexpress69)\
**Post date:** [November 27, 2015, 9:55am UTC](https://discuss.emberjs.com/t/add-ds-store-base-delegate-method-to-the-adapter/9181/2 "2015-11-27T09:55:30Z")

</div>

Sorry, but I don’t get why `query()` does not work for you? I am using `query()` for all of my requests to a paged API, even for sort and filtering. All you have to to is to add some queryParams to you route…

As for non-standard URLs: You can tweak the URL either in the adapter or you are free to do things like that to circumvent the adapter and ORM completely:

```
  actions: {
    // this cancels the subscription by issuing a non-standard ajax call
    cancel: function(param) {
      Ember.Logger.info("Huh?");
      // get token and add it to the request header of our ajax call
      this.get('session').authorize('authorizer:custom', (headerName, headerValue) => {
        const headers = {};
        headers[headerName] = headerValue;
        Ember.$.ajax({
          url: "http:// ****** /v1/subscriptions/" + param + "/cancel/",
          type: "POST",
          data: null,
          headers
        }).then(
          this.onSuccessfulCancel.bind(this),
          this.onFailedCancel.bind(this)
        );
      });
    },
  },

```

Regards,

Martin

---

<div class="post-metadata">

**Author:** ![teckays](https://avatars.discourse-cdn.com/v4/letter/t/258eb7/32.png) [@teckays](https://discuss.emberjs.com/u/teckays)\
**Post date:** [November 27, 2015, 9:41pm UTC](https://discuss.emberjs.com/t/add-ds-store-base-delegate-method-to-the-adapter/9181/3 "2015-11-27T21:41:49Z")

</div>

As I mentioned in the OP, the endpoint responsible for search uses another url schema, `query()` will make a request to `/{model}` while I had to fetch `/{model}/search` and also pass some other parameters. Anyway, I have made the changes from the API server and created a separate `search` model in order to be able to fetch it the other way, like `/search/{model}`

---

<div class="post-metadata">

**Author:** ![planetexpress69](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/planetexpress69/32/11530_2.png) [@planetexpress69](https://discuss.emberjs.com/u/planetexpress69)\
**Post date:** [November 30, 2015, 8:58am UTC](https://discuss.emberjs.com/t/add-ds-store-base-delegate-method-to-the-adapter/9181/4 "2015-11-30T08:58:50Z")

</div>

Still a valid idea to overwrite `urlForQuery` in your adapter to customize the API’s endpoint…

Regards, Martin
