Defining common api namespace for set of models

Hi All,

Currently for all models, I defined namespace in application adaptor. Now i am adding new models which require new namespace. I need both namespace in single application.

One way is adding adaptor for each models with namespace. is there any way to define one adaptor which define namespace for set of models?

There are three primary ways to do this (at least that I’m aware of):

  1. define an adapter for each model that sets the namespace on a per-model basis (what you mentioned above)

  2. define two base adapters with different namespaces, and an adapter for each model that simply extends the right base adapter

  3. “namespace” your models too, meaning nesting your models under subdirectories. For example if you have a model defined in app/models/vegetables/tomato by default it will make requests to /vegetables/tomato. The upside to this method is that no adapter customization is required. The downside is that any reference to the model needs to be namespaced e.g. store.query('vegetables/tomato')

2 Likes

Thanks @dknutsen . It helps.

if using adapters you can also just write two adapters and implement adapterFor and toggle based on a list of which belongs to which.

Though its a lot simpler to handle this using a builder and store.request