Track database versioning & include in Node version data
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-11-02 15:53:39 -06:00
parent 3bef5f3423
commit 9398c827ed
3 changed files with 30 additions and 8 deletions

View File

@@ -75,6 +75,12 @@ class Node extends VersionedModel {
if ( group ) {
data.associated_type_version_num = group.version_num
}
} else if ( this.Type === 'database_ref' && this.Value?.Value ) {
const Database = this.models.get('api:db:Database')
const db = await Database.findOne({ Active: true, UUID: this.Value?.Value })
if ( db ) {
data.associated_type_version_num = db.version_num
}
}
return data

View File

@@ -1,4 +1,4 @@
const Model = require('flitter-orm/src/model/Model')
const VersionedModel = require('../../VersionedModel')
const uuid = require('uuid/v4')
const ColumnDef = require('./ColumnDef.model')
const Page = require('../Page.model')
@@ -10,10 +10,11 @@ const ActiveScope = require('../../scopes/Active.scope')
* -------------------------------------------------------------
* Put some description here!
*/
class Database extends Model {
class Database extends VersionedModel {
static get schema() {
// Return a flitter-orm schema here.
return {
...super.schema,
Name: String,
NodeId: String,
PageId: String,
@@ -52,7 +53,7 @@ class Database extends Model {
async delete() {
this.Active = false
await this.save()
await this.version_save(`Deleted`)
}
to_api_object() {
@@ -61,6 +62,8 @@ class Database extends Model {
uuid: this.UUID,
page_id: this.PageId,
column_ids: this.ColumnIds,
version_num: this.version_num,
version_message: this.version_message,
}
}
}