Add active scope to Codium model and set on delete (#11)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2020-10-13 10:16:21 -05:00
parent a0b5003087
commit 597c269cd9
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
2 changed files with 6 additions and 1 deletions

View File

@ -88,7 +88,8 @@ class FormCode extends Controller {
const code = await Codium.findOne({UUID: req.params.CodiumId}) const code = await Codium.findOne({UUID: req.params.CodiumId})
if ( !code ) return res.status(404).message('Unable to find code with that ID.').api({}) if ( !code ) return res.status(404).message('Unable to find code with that ID.').api({})
await code.delete() code.Active = false
await code.save()
return res.api({}) return res.api({})
} }
} }

View File

@ -1,5 +1,6 @@
const Model = require('flitter-orm/src/model/Model') const Model = require('flitter-orm/src/model/Model')
const uuid = require('uuid/v4') const uuid = require('uuid/v4')
const ActiveScope = require('../scopes/Active.scope')
/* /*
* Codium Model * Codium Model
@ -15,8 +16,11 @@ class Codium extends Model {
PageId: String, PageId: String,
code: String, code: String,
UUID: { type: String, default: () => uuid() }, UUID: { type: String, default: () => uuid() },
Active: { type: Boolean, default: true },
} }
} }
static scopes = [new ActiveScope]
// Static and instance methods can go here // Static and instance methods can go here
get page() { get page() {