View Full Version : How to access a model in another schema?

17 Apr 2014, 7:50 AM
Let's take an example app. I have a common module with a bunch of models. They all use the default Schema.
I have 2 other modules billing and inventory. They have their own schema. Each transaction creates a session and the schema representing that module is attached to the session.

| \---model
| Base.js
| Customer.js
| Order.js
| \---model
| Base.js
| Policy.js
| User.js

In my billing view model, when I reference an entityName (Customer) it looks it up in the billing schema attached to the current session.

I saw the ticket app where all the models are placed under one schema, but that's not a viable option in my case. Each module will internally have sub modules with their own models and such.

So is there a way to access the Item model from the inventory schema or Policy model from the default schema in the billing view model?

There is no association between models across schemas. I just need to load models from another schema to populate a combo box or things like that. Those models will not be mutated (only reads).

17 Apr 2014, 8:05 AM
What do you mean by:

access the Item model from the inventory schema

You can just specify the full model name if you want to use it in a store.

17 Apr 2014, 8:15 AM
The session in the billing view model is using the billing schema. If I want to create an items store in the billing view model using the Item model (which is part of the inventory schema), all I have to do is specify it with the fully qualified name (Example.inventory.model.Item)?

Thought I tried this and it didn't work. Must have goofed up elsewhere.

Thanks Evan!