@tugou/midway
Advanced tools
| export declare class BaseModel { | ||
| entity: any; | ||
| findOne(options: object): Promise<any>; | ||
| create(values: object, options?: any): Promise<any>; | ||
| create(values: any, options?: any): Promise<any>; | ||
| private filterNull; | ||
| bulkCreate(values: Array<object>, options?: object): Promise<any>; | ||
| update(values: object, options: any): Promise<any>; | ||
| bulkCreate(values: Array<any>, options?: object): Promise<any>; | ||
| update(values: any, options: any): Promise<any>; | ||
| destroySoft(options: object): Promise<any>; | ||
| destroy(options: object): Promise<any>; | ||
@@ -9,0 +10,0 @@ count(options: object): Promise<any>; |
+17
-1
@@ -11,2 +11,3 @@ "use strict"; | ||
| const decorator_1 = require("@midwayjs/decorator"); | ||
| const baimahu_1 = require("@tugou/baimahu"); | ||
| let BaseModel = class BaseModel { | ||
@@ -27,2 +28,3 @@ async findOne(options) { | ||
| this.filterNull(values, options); | ||
| values.create_time = values.update_time = baimahu_1.moment.now(); | ||
| let ret = await this.entity.create(values, options); | ||
@@ -51,4 +53,6 @@ ret = ret.toJSON(); | ||
| try { | ||
| for (const obj of values) | ||
| for (const obj of values) { | ||
| this.filterNull(obj, options); | ||
| obj.create_time = obj.update_time = baimahu_1.moment.now(); | ||
| } | ||
| let ret = await this.entity.bulkCreate(values, options); | ||
@@ -69,2 +73,3 @@ console.info('[sequelize] [bulkCreate] ', JSON.stringify(ret)); | ||
| return 0; | ||
| values.update_time = baimahu_1.moment.now(); | ||
| const ret = await this.entity.update(values, options); | ||
@@ -80,2 +85,13 @@ console.info('[sequelize] [update] ', ret); | ||
| } | ||
| async destroySoft(options) { | ||
| try { | ||
| const ret = await this.entity.update({ delete_time: baimahu_1.moment.now() }, options); | ||
| console.info('[sequelize] [destroySoft] ', ret); | ||
| return ret; | ||
| } | ||
| catch (e) { | ||
| console.error('[sequelize] [destroySoft] ', e); | ||
| return false; | ||
| } | ||
| } | ||
| async destroy(options) { | ||
@@ -82,0 +98,0 @@ try { |
+4
-3
| { | ||
| "name": "@tugou/midway", | ||
| "version": "1.2.7", | ||
| "version": "1.2.8", | ||
| "description": "tugou midway", | ||
@@ -8,3 +8,4 @@ "main": "dist/index", | ||
| "scripts": { | ||
| "build": "scripty" | ||
| "build": "scripty", | ||
| "link": "scripty" | ||
| }, | ||
@@ -39,3 +40,3 @@ "keywords": [ | ||
| "license": "MIT", | ||
| "gitHead": "712e421b83fc6601a80c2a928140514a99845582" | ||
| "gitHead": "fce27d781062fcb06be645f6748f21a7ca70101f" | ||
| } |
28790
2.48%720
2.42%