ember-learn / ember-learn/guides-source

Ember Data Model Nesting/Namespacing

Open
#1,788 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
161
Forks
512
Avg merge
4d 9h
Merged PRs (30d)
4

Description

One thing I stumbled upon when trying Ember Data is the seemingly lack of support for namespaced data models. Running `ember generate model user/google` generates a UserGoogle model in `app/models/user/google.js`.

However, the issue is that Ember Data itself does not seem to support namespaced model names. I assume the [JSON API spec](https://jsonapi.org/format/#document-member-names) does not allow `/` in the [resource `type`](https://jsonapi.org/format/#document-resource-object-identification), so Ember Data assumes no model will ever be namespaced. When trying to do Ember Data operations like finding a specific resource, Ember Data seems to error out trying to load the class.

When using the same code but doing `ember generate model userGoogle`, the code works. It generates files like `app/models/user-google.js`.

I think a note should be added to the guides if there is indeed a limitation with namespaced Ember Data model names. I assumed that model namespaces would be supported because routes and components support namespaces.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.