set up orders model and relationships
This commit is contained in:
@@ -39,7 +39,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"validations": [],
|
"validations": [],
|
||||||
"relations": {},
|
"relations": {
|
||||||
|
"orders": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "order",
|
||||||
|
"foreignKey": "customerId"
|
||||||
|
}
|
||||||
|
},
|
||||||
"acls": [],
|
"acls": [],
|
||||||
"methods": {}
|
"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": [],
|
"validations": [],
|
||||||
"relations": {},
|
"relations": {
|
||||||
|
"orders": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "order",
|
||||||
|
"foreignKey": "",
|
||||||
|
"through": "orderProducts"
|
||||||
|
}
|
||||||
|
},
|
||||||
"acls": [],
|
"acls": [],
|
||||||
"methods": {}
|
"methods": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"RoleMapping": 1,
|
"RoleMapping": 1,
|
||||||
"Role": 1,
|
"Role": 1,
|
||||||
"customer": 1,
|
"customer": 1,
|
||||||
"product": 1
|
"product": 1,
|
||||||
|
"order": 1
|
||||||
},
|
},
|
||||||
"models": {
|
"models": {
|
||||||
"User": {},
|
"User": {},
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
"RoleMapping": {},
|
"RoleMapping": {},
|
||||||
"Role": {},
|
"Role": {},
|
||||||
"customer": {},
|
"customer": {},
|
||||||
"product": {}
|
"product": {},
|
||||||
|
"order": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,16 @@
|
|||||||
"dataSource": "db",
|
"dataSource": "db",
|
||||||
"public": true
|
"public": true
|
||||||
},
|
},
|
||||||
|
"order": {
|
||||||
|
"dataSource": "db",
|
||||||
|
"public": true
|
||||||
|
},
|
||||||
"product": {
|
"product": {
|
||||||
"dataSource": "db",
|
"dataSource": "db",
|
||||||
"public": true
|
"public": true
|
||||||
|
},
|
||||||
|
"orderProducts": {
|
||||||
|
"dataSource": "db",
|
||||||
|
"public": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user