Add active scope to Codium model and set on delete (#11)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a0b5003087
commit
597c269cd9
@ -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({})
|
||||
}
|
||||
}
|
||||
|
@ -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,9 +16,12 @@ 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() {
|
||||
const Page = require('./Page.model')
|
||||
|
Loading…
Reference in New Issue
Block a user