I am having a problem in my code .. the thing is i want to store some data from an ember js applications using loopback api and mongodb
actually i have two problems
first one is that the data i want to store into the database is stored in a "data" key and i can't access it "no idea why"
Here is my template
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Per Minute </span>
</div>
</div>
<br />
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">˚C</span>
</div>
</div>
<br />
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">to</span>
</div>
</div>
<br />
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Per Minute</span>
</div>
</div>
<br />
</div>
<button class="btn btn-primary pull-right"> Save </button>
Here is my controller :
addOrder(services, doctor, patient, visit){
patient.then((patient)=>{
doctor.then((doctor)=>{
var order = this.store.createRecord('order',{
doctor:doctor,
patient:patient,
visit:visit
})
visit.get('orders').pushObject(order);
patient.get('orders').pushObject(order);
order.get('services').pushObjects(services);
order.save().then(()=>{
patient.save();
doctor.save();
})
})
})
}
My order.json :
{
"name": "order",
"plural": "orders",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {},
"validations": [],
"relations": {
"patient": {
"type": "belongsTo",
"model": "patient",
"foreignKey": "",
"primaryKey": "id"
},
"doctor": {
"type": "belongsTo",
"model": "employee",
"foreignKey": "",
"primaryKey": "id"
},
"visits": {
"type": "belongsTo",
"model": "visit",
"foreignKey": "",
"primaryKey": "id"
},
"services": {
"type": "hasMany",
"model": "services",
"foreignKey": "",
"primaryKey": "id"
}
},
"acls": [],
"methods": {}
}
Aucun commentaire:
Enregistrer un commentaire