Track code snippet versions & include in the node version data
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-11-02 12:47:34 -06:00
parent 3b9d8acccb
commit a584631b75
3 changed files with 21 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
const Model = require('flitter-orm/src/model/Model')
const VersionedModel = require('../VersionedModel')
const uuid = require('uuid/v4')
const ActiveScope = require('../scopes/Active.scope')
@@ -7,10 +7,11 @@ const ActiveScope = require('../scopes/Active.scope')
* -------------------------------------------------------------
* Put some description here!
*/
class Codium extends Model {
class Codium extends VersionedModel {
static get schema() {
// Return a flitter-orm schema here.
return {
...super.schema,
Language: {type: String, default: 'javascript'},
NodeId: String,
PageId: String,

View File

@@ -58,6 +58,21 @@ class Node extends VersionedModel {
if ( data.Type ) this.Type = data.Type
if ( data.Value ) this.Value = data.Value
}
async cast_to_version_data() {
const data = await super.cast_to_version_data()
// If supported, fetch the current version of the node item
if ( this.Type === 'code_ref' && this.Value?.Value ) {
const Codium = this.models.get('api:Codium')
const code = await Codium.findOne({ UUID: this.Value?.Value, Active: true })
if ( code ) {
data.associated_type_version_num = code.version_num
}
}
return data
}
}
module.exports = exports = Node;