Browse Source
fix: foreign key constraint when page have comments (#2199)
* Solving foreing key contraint when page have comments
* Update pages.js
remove indentation changes
Co-authored-by: Higor Tavares <paulo.freire@dellead.com>
pull/2269/head
Higor Tavares
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
9 additions and
1 deletions
-
server/models/pages.js
|
@ -119,7 +119,15 @@ module.exports = class Page extends Model { |
|
|
this.createdAt = new Date().toISOString() |
|
|
this.createdAt = new Date().toISOString() |
|
|
this.updatedAt = new Date().toISOString() |
|
|
this.updatedAt = new Date().toISOString() |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* Solving the violates foreign key constraint using cascade strategy |
|
|
|
|
|
* using static hooks |
|
|
|
|
|
* @see https://vincit.github.io/objection.js/api/types/#type-statichookarguments
|
|
|
|
|
|
*/ |
|
|
|
|
|
static async beforeDelete({ asFindQuery }) { |
|
|
|
|
|
const page = await asFindQuery().select('id') |
|
|
|
|
|
await WIKI.models.comments.query().delete().where('pageId', page[0].id) |
|
|
|
|
|
} |
|
|
/** |
|
|
/** |
|
|
* Cache Schema |
|
|
* Cache Schema |
|
|
*/ |
|
|
*/ |
|
|
xxxxxxxxxx