I’m trying to create a transaction to create a new user.
From the ember-data.js src:
To create a new transaction, call the
transaction()method of your
application’sDS.Storeinstance:var transaction = App.store.transaction();
I’m trying to create the transaction in a controller
App.CreateUserController = Ember.Controller.extend({
addUser: function() {
var transaction = App.store.transaction();
}
});
but I’m getting
TypeError: App.store is undefined
I had this store defined
App.Store = DS.Store.extend({
revision: 11,
adapter: App.Adapter.create({})
});
it used a captial S so I tried changing App.store to App.Store and I get
TypeError: App.Store.transaction is not a function
If I change my App.Store to use a lowercase s I get
TypeError: store is undefined
Am I missing something?
You need to create a store instead of extending it. The convention is to use lowercase letters when you create an instance, so instead of App.Store, you should create a store and name it App.store
Then you’ll be able to create a transaction