Comments (2)
OK, digged a bit deeper through the code and specifically https://github.com/emberjs/data/blob/5a48f52a08587e59cb529575577880daf678ae00/packages/store/src/-types/q/schema-service.ts the last portion. As it turns out I have the polymorphic: true
at the wrong level. It should be in the options
menu model:
{
action: {
name: 'action',
kind: 'belongsTo',
options: {
polymorphic: true,
async: true,
inverse: null
}
}
}
Seems like I don't have to specify a type
because with this I'm able to push data into the store and then I can happily request it from the store without errors. The only extra thing I have to do is to make sure the models exists when data is pushed, so first fetch the model before pushing into the store.
from data.
For inverse: null
yes, there is nothing additionally needed though you are missing the abstract type and should make sure you include it.
{
action: {
name: 'action',
kind: 'belongsTo',
+ type: 'action', // I'm guessing here that the abstract type is also "action"
options: {
polymorphic: true,
async: true,
inverse: null
}
}
}
For inverse: <some-prop>
the corresponding field on the other record must specify the abstract type. So for instance, assume menu said this:
{
action: {
name: 'action',
kind: 'belongsTo',
+ type: 'action',
options: {
polymorphic: true,
async: true,
+ inverse: 'lists'
}
}
}
Then any record that satisfies "action" must have the below field def:
// "add-item" action
{
lists: {
name: 'lists',
kind: 'hasMany',
type: 'menu',
options: {
async: true,
inverse: 'action',
as: 'action'
}
}
}
as
here is what allows any type to act as the abstract type. Note, the entire field configuration must identically match across all types that satisfy this polymorphic trait.
from data.
Related Issues (20)
- docs: turning store.request document into record(s) is not documented HOT 1
- BUG: Cannot set host relative to site root
- bug: Setting hasMany relationship IDs to an array with duplicate IDs should error HOT 1
- return type of peekRequest is incorrect in the api docs
- is there a design flaw in request lifetimes? HOT 9
- design issue: fetch handler doesn't provide response on error HOT 3
- bug: typescript error when using computed properties in conditionals HOT 1
- bug: async-to-async relationships may error when using `unloadAll` on both types HOT 12
- Preloading polymorphic relationship breaks on ember-data 5.3 HOT 2
- Feat - Additional Functionality Support in RequestManager for handler for Dynamic Handling beyond 'request' HOT 3
- Broken link in JSON Api ReadMe HOT 1
- cache.rollbackRelationships does not rollback the 2nd time after adding a record and rollback again HOT 3
- Assertion after saving a new relational record and tried to forget it HOT 4
- [3.28->4.7] `isLoaded` does not recompute if checked before the record has loaded. HOT 6
- Error `Could not find module `@warp-drive/core-types/request` imported from `(require)`` after update to 5.3.1 HOT 15
- ember-data date transform: triggering change on record re-insertion HOT 6
- bug: not tracking changes to empty relationship in 5.3.1+
- Breaks yarn install on Windows HOT 5
- Build broken after update from `5.3.0` to `5.3.3` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data.