I’m new working with Ember.js and I’m confused about a few things. My real issue is working with MySQL and ember-data. I’ve worked through a few tutorials and found this youtube very useful. At this point, I can create an app that runs on top of a Node.js server. The node server communicates with a mysql database and creates a RESTful API that the ember app consumes. I have no problem getting data from the mysql database and displaying it. But I cannot figure out how to save or update data in the MySQL database. I vaguely understand the concept of the ‘store’ and can push objects into it and display them, but that's it. Are there any examples out there of how to write or update a mysql database using ember-data and Node.js?
This is an example of pushing into the store in the routes/message.js
import Ember from 'ember';
export default Ember.Route.extend({
model() {
var self = this;
setTimeout(function(){
console.log("done waiting...")
self.store.push({
data: [{
id: 11,
type: 'message',
attributes: {
message: 'New Message'
},
relationships: {}
}]
});
},1000);
return self.store.findAll('message');
}
});
Aucun commentaire:
Enregistrer un commentaire