|
@@ -101,6 +101,21 @@ module.exports = async (dbName='shop') => {
|
|
|
image: "category",
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ static get defaultPermissions(){
|
|
|
+ return {
|
|
|
+ //savable refs, objectid's, words like 'tags' or 'roles'
|
|
|
+ read: ['owner', 'user'],
|
|
|
+ write: ['owner', 'admin'],
|
|
|
+ create: ['user'],
|
|
|
+ delete: ['admin', 'owner'],
|
|
|
+
|
|
|
+ /*permission
|
|
|
+ * TODO: permissions for read and write permissions
|
|
|
+ *
|
|
|
+ */
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
SlicedSavable.addClass(Category)
|
|
|
|
|
@@ -118,6 +133,22 @@ module.exports = async (dbName='shop') => {
|
|
|
orderGoods: "order"
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ static get defaultPermissions(){
|
|
|
+ return {
|
|
|
+ //savable refs, objectid's, words like 'tags' or 'roles'
|
|
|
+ read: ['owner', 'admin'],
|
|
|
+ write: ['owner', 'admin'],
|
|
|
+ create: ['user'],
|
|
|
+ delete: ['admin'],
|
|
|
+
|
|
|
+ /*permission
|
|
|
+ * TODO: permissions for read and write permissions
|
|
|
+ *
|
|
|
+ */
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
SlicedSavable.addClass(Order)
|
|
|
|
|
@@ -130,6 +161,13 @@ module.exports = async (dbName='shop') => {
|
|
|
return this.price*this.count
|
|
|
}
|
|
|
|
|
|
+ async save(...params){
|
|
|
+ if (!this.price && this.good && this.good.price){
|
|
|
+ this.price = this.good.price
|
|
|
+ }
|
|
|
+ return await super.save(...params)
|
|
|
+ }
|
|
|
+
|
|
|
static get relations(){
|
|
|
return {
|
|
|
good: ["orderGoods"],
|