Add delete for pages, active scope to model

This commit is contained in:
garrettmills
2020-02-08 15:27:53 -06:00
parent 29a873559b
commit f720e334b3
4 changed files with 124 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ const Model = require("flitter-orm/src/model/Model");
const { ObjectId } = require("mongodb");
const uuid = require('uuid/v4');
const ActiveScope = require('../scopes/Active.scope')
/*
* Page Model
* -------------------------------------------------------------
@@ -23,12 +25,16 @@ class Page extends Model {
NodeIds: [String],
CreatedAt: {type: Date, default: () => new Date},
UpdatedAt: {type: Date, default: () => new Date},
DeletedAt: Date,
Active: {type: Boolean, default: true},
CreatedUserId: {type: String},
UpdateUserId: {type: String},
ChildPageIds: [String],
};
}
static scopes = [new ActiveScope]
// Static and instance methods can go here
get user() {
const User = this.models.get("auth:User");

View File

@@ -0,0 +1,9 @@
const Scope = require('flitter-orm/src/model/Scope')
class ActiveScope extends Scope {
async filter(to_filter) {
return to_filter.equal('Active', true)
}
}
module.exports = exports = ActiveScope