feat: branch off / create from template

This commit is contained in:
NGPixel
2020-03-01 18:22:26 -05:00
committed by Nicolas Giard
parent e85de92715
commit 13a995133b
7 changed files with 142 additions and 21 deletions

View File

@@ -84,6 +84,9 @@ module.exports = class PageHistory extends Model {
this.createdAt = new Date().toISOString()
}
/**
* Create Page Version
*/
static async addVersion(opts) {
await WIKI.models.pageHistory.query().insert({
pageId: opts.id,
@@ -105,6 +108,9 @@ module.exports = class PageHistory extends Model {
})
}
/**
* Get Page Version
*/
static async getVersion({ pageId, versionId }) {
const version = await WIKI.models.pageHistory.query()
.column([
@@ -134,13 +140,20 @@ module.exports = class PageHistory extends Model {
'pageHistory.id': versionId,
'pageHistory.pageId': pageId
}).first()
return {
...version,
updatedAt: version.createdAt,
tags: []
if (version) {
return {
...version,
updatedAt: version.createdAt || null,
tags: []
}
} else {
return null
}
}
/**
* Get History Trail of a Page
*/
static async getHistory({ pageId, offsetPage = 0, offsetSize = 100 }) {
const history = await WIKI.models.pageHistory.query()
.column([