feat: save page + create event for storage targets

This commit is contained in:
NGPixel
2018-07-22 16:25:39 -04:00
parent cb84df7a53
commit 076e923d48
22 changed files with 158 additions and 89 deletions

View File

@@ -1,5 +1,7 @@
const Model = require('objection').Model
/* global WIKI */
/**
* Pages model
*/
@@ -75,4 +77,22 @@ module.exports = class Page extends Model {
this.createdAt = new Date().toISOString()
this.updatedAt = new Date().toISOString()
}
static async createPage(opts) {
const page = await WIKI.db.pages.query().insertAndFetch({
authorId: opts.authorId,
content: opts.content,
description: opts.description,
editorKey: opts.editor,
isPrivate: opts.isPrivate,
isPublished: opts.isPublished,
localeCode: opts.locale,
path: opts.path,
publishEndDate: opts.publishEndDate,
publishStartDate: opts.publishStartDate,
title: opts.title
})
await WIKI.db.storage.createPage(page)
return page
}
}