Add version tracking for page nodes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-11-02 12:31:05 -06:00
parent 6469beb341
commit 40eb3bb1f2
4 changed files with 16 additions and 15 deletions

View File

@@ -17,17 +17,18 @@ class VersionedModel extends Model {
}
async new_version(message = undefined, user_id = undefined) {
const version_data = await this.cast_to_version_data()
version_data.version_UUID = uuid()
version_data.version_message = message
if ( !this.version_num ) this.version_num = 1
if ( !this.version_archive ) this.version_archive = []
this.version_num += 1
this.version_archive.push(version_data)
this.version_create_date = new Date()
this.version_user_id = user_id
const version_data = await this.cast_to_version_data()
version_data.version_UUID = uuid()
version_data.version_message = message
this.version_archive.push(version_data)
}
async cast_to_version_data() {

View File

@@ -1,12 +1,12 @@
const Model = require("flitter-orm/src/model/Model");
const uuid = require('uuid/v4');
const VersionedModel = require('../VersionedModel')
const uuid = require('uuid/v4')
/*
* Node Model
* -------------------------------------------------------------
* Put some description here!
*/
class Node extends Model {
class Node extends VersionedModel {
static get services() {
return [...super.services, 'models']
}
@@ -14,6 +14,7 @@ class Node extends Model {
static get schema() {
// Return a flitter-orm schema here.
return {
...super.schema,
UUID: { type: String, default: () => uuid() },
Type: String,
Value: {