From 597c269cd9dffa39d30130f1470880fd89a4ca27 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Tue, 13 Oct 2020 10:16:21 -0500 Subject: [PATCH] Add active scope to Codium model and set on delete (#11) --- app/controllers/api/v1/FormCode.controller.js | 3 ++- app/models/api/Codium.model.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/FormCode.controller.js b/app/controllers/api/v1/FormCode.controller.js index 630b242..00335c0 100644 --- a/app/controllers/api/v1/FormCode.controller.js +++ b/app/controllers/api/v1/FormCode.controller.js @@ -88,7 +88,8 @@ class FormCode extends Controller { const code = await Codium.findOne({UUID: req.params.CodiumId}) 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({}) } } diff --git a/app/models/api/Codium.model.js b/app/models/api/Codium.model.js index d8c72b4..4a91674 100644 --- a/app/models/api/Codium.model.js +++ b/app/models/api/Codium.model.js @@ -1,5 +1,6 @@ const Model = require('flitter-orm/src/model/Model') const uuid = require('uuid/v4') +const ActiveScope = require('../scopes/Active.scope') /* * Codium Model @@ -15,8 +16,11 @@ class Codium extends Model { PageId: String, code: String, UUID: { type: String, default: () => uuid() }, + Active: { type: Boolean, default: true }, } } + + static scopes = [new ActiveScope] // Static and instance methods can go here get page() {