Ich habe ein Problem mit Loopback, ich möchte versuchen, an eine andere Tabelle POST. aber es kann nicht. hier der Code, den ich bei http://localhost:1337/explorer/#!/Order/Order_createPost zu zwei Tabellen Loopback
{
"Code": "ASDASDASDE",
"DP": 0,
"Discount": 0,
"DiscountNominal": 0,
"TotalPrice": 0,
"RequestDate": "string",
"DeliveryDate": "2017-06-22T07:14:18.815Z",
"TotalQty": 0,
"Destination": "string",
"Phone": "string",
"Status": "string",
"PaymentType": "string",
"DealerCode": "D912839",
"Active": true,
"Deleted": true,
"CreatedBy": "string",
"CreatedDate": "2017-06-22T07:14:18.815Z",
"CreateAgent": "string",
"UpdatedBy": "string",
"UpdatedDate": "2017-06-22T07:14:18.815Z",
"UpdateAgent": "string",
"KioskCode": "A1234",
"orderDetails":[{
"Code": "ASD123",
"IsRetur": true,
"Price": 0,
"IMEI": "string",
"Status": "string",
"OrderCode": "ASDASDASDE",
"ProductCode": "SM-1923",
"Active": true,
"Deleted": true,
"CreatedBy": "string",
"CreatedDate": "2017-06-22T07:14:19.045Z",
"CreateAgent": "string",
"UpdatedBy": "string",
"UpdatedDate": "2017-06-22T07:14:19.045Z",
"UpdateAgent": "string"
}]
}
Lassen Sie uns sagen Loopback Explorer zu stellen, ich zu Tisch bestellen zu stellen, und Tabelle Auftragsdetail in der Apostroph von JSON. Die Auftragstabelle wurde eingefügt, die Auftragsdetaillentabelle konnte dies jedoch nicht.
hier mein Order.JSON
{
"name": "Order",
"plural": "Order",
"base": "PersistedModel",
"idInjection": false,
"options": {
"validateUpsert": true
},
"mixins": {
"TimeStamp": {}
},
"properties": {
"Code": {
"type": "string",
"id": true,
"required": true
....
},
"validations": [],
"relations": {
"Dealer": {
"type": "belongsTo",
"model": "Dealer",
"foreignKey": "DealerCode"
},
"orderDetails": {
"type": "hasMany",
"model": "OrderDetail",
"foreignKey": "OrderCode"
},
"Kiosk": {
"type": "belongsTo",
"model": "Kiosk",
"foreignKey": "KioskCode"
}
},
"acls": [],
"methods": {}
}
hier mein orderDetail.JSON
{
"name": "OrderDetail",
"plural": "orderDetails",
"base": "PersistedModel",
"idInjection": false,
"options": {
"validateUpsert": true
},
"mixins": {
"TimeStamp": {}
},
"properties": {
"Code": {
"type": "string",
"id": true,
"required": true
}
.....
},
"validations": [],
"relations": {
"Order": {
"type": "belongsTo",
"model": "Order",
"foreignKey": "OrderCode"
},
"Product": {
"type": "belongsTo",
"model": "Product",
"foreignKey": "ProductCode"
}
},
"acls": [],
"methods": {}
}
Der Auftrag hat primaryKey: Code und Orderdetails einen Fremdschlüssel hat: Ordercode, die Verweise auf Bestellung: Code. was zur lösung ?? Danke für die Hilfe
hallo, Tash, danke für die Antwort, es ist wie perfekt aussieht, aber wenn ich die Remotecode versuchen, gründete ich den Fehler, weil die app.models. wurde nicht mehr benötigt. Groß! Prost! –