How to access the Ember datastore from the console?

In Ember 2+, does anyone know how to get a link to the Ember Store to eliminate model mapping in the javascript console?

In Ember 1, this was possible through the App.__container__.lookup , but this no longer exists, and it’s hard to find documentation about this.

thanks

+5
source share
1 answer

If you look in package.json , you will see the ember-export-application-global package, which is installed by default (if not, install it). This does not export your application to a global App object, but to a global object named after your application. That way you can have window.TodoList or window.ShoppingCart instead of window.App . From there you can use this line (similar to Ember 1.xx):

 AppName.__container__.lookup('service:store') 

You can also do what I do and create an instance initializer for it:

 export default { name: 'store-on-app', after: 'ember-data', initialize(instance) { const application = instance.container.lookup('application:main'); const store = instance.container.lookup('service:store'); application.set('store', store); } } 

Then you can just user AppName.store .

+11
source

Source: https://habr.com/ru/post/1233055/


All Articles