set up orders model and relationships
This commit is contained in:
@@ -39,7 +39,13 @@
|
||||
}
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"relations": {
|
||||
"orders": {
|
||||
"type": "hasMany",
|
||||
"model": "order",
|
||||
"foreignKey": "customerId"
|
||||
}
|
||||
},
|
||||
"acls": [],
|
||||
"methods": {}
|
||||
}
|
||||
|
||||
5
common/models/order-products.js
Normal file
5
common/models/order-products.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(Orderproducts) {
|
||||
|
||||
};
|
||||
41
common/models/order-products.json
Normal file
41
common/models/order-products.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "orderProducts",
|
||||
"base": "PersistedModel",
|
||||
"idInjection": true,
|
||||
"options": {
|
||||
"validateUpsert": true
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"quantity": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"price": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"totalPrice": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {
|
||||
"order": {
|
||||
"type": "belongsTo",
|
||||
"model": "order",
|
||||
"foreignKey": ""
|
||||
},
|
||||
"product": {
|
||||
"type": "belongsTo",
|
||||
"model": "product",
|
||||
"foreignKey": ""
|
||||
}
|
||||
},
|
||||
"acls": [],
|
||||
"methods": {}
|
||||
}
|
||||
5
common/models/order.js
Normal file
5
common/models/order.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(Order) {
|
||||
|
||||
};
|
||||
38
common/models/order.json
Normal file
38
common/models/order.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "order",
|
||||
"plural": "orders",
|
||||
"base": "PersistedModel",
|
||||
"idInjection": true,
|
||||
"options": {
|
||||
"validateUpsert": true
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"total": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"datetime": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {
|
||||
"customer": {
|
||||
"type": "belongsTo",
|
||||
"model": "customer",
|
||||
"foreignKey": ""
|
||||
},
|
||||
"products": {
|
||||
"type": "hasMany",
|
||||
"model": "product",
|
||||
"foreignKey": "",
|
||||
"through": "orderProducts"
|
||||
}
|
||||
},
|
||||
"acls": [],
|
||||
"methods": {}
|
||||
}
|
||||
@@ -28,7 +28,14 @@
|
||||
}
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"relations": {
|
||||
"orders": {
|
||||
"type": "hasMany",
|
||||
"model": "order",
|
||||
"foreignKey": "",
|
||||
"through": "orderProducts"
|
||||
}
|
||||
},
|
||||
"acls": [],
|
||||
"methods": {}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"RoleMapping": 1,
|
||||
"Role": 1,
|
||||
"customer": 1,
|
||||
"product": 1
|
||||
"product": 1,
|
||||
"order": 1
|
||||
},
|
||||
"models": {
|
||||
"User": {},
|
||||
@@ -15,6 +16,7 @@
|
||||
"RoleMapping": {},
|
||||
"Role": {},
|
||||
"customer": {},
|
||||
"product": {}
|
||||
"product": {},
|
||||
"order": {}
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,16 @@
|
||||
"dataSource": "db",
|
||||
"public": true
|
||||
},
|
||||
"order": {
|
||||
"dataSource": "db",
|
||||
"public": true
|
||||
},
|
||||
"product": {
|
||||
"dataSource": "db",
|
||||
"public": true
|
||||
},
|
||||
"orderProducts": {
|
||||
"dataSource": "db",
|
||||
"public": false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user