Update page model relationships

This commit is contained in:
garrettmills 2020-02-08 08:07:26 -06:00
parent ef2e315480
commit 7c8bcd928f

View File

@ -16,7 +16,7 @@ class Page extends Model {
return { return {
UUID: {type: String, default: () => uuid()}, UUID: {type: String, default: () => uuid()},
Name: String, Name: String,
OrgUserId: String, OrgUserId: ObjectId,
IsPublic: {type: Boolean, default: true}, IsPublic: {type: Boolean, default: true},
IsVisibleInMenu: {type: Boolean, default: true}, IsVisibleInMenu: {type: Boolean, default: true},
ParentId: String, ParentId: String,
@ -37,16 +37,16 @@ class Page extends Model {
get nodes() { get nodes() {
const Node = this.models.get("api:Node"); const Node = this.models.get("api:Node");
return this.has_many(Node, "NodeIds", "_id"); return this.has_many(Node, "NodeIds", "UUID");
} }
get childPages() { get childPages() {
const Page = this.models.get("api:Page") const Page = this.models.get("api:Page")
return this.has_many(Page, "ChildPageIds", "_id") return this.has_many(Page, "ChildPageIds", "UUID")
} }
get parent() { get parent() {
const Parent = this.models.get("api:Page") const Parent = this.models.get("api:Page")
return this.belongs_to_one(Parent, "ParentId", "_id") return this.belongs_to_one(Parent, "ParentId", "UUID")
} }
accessible_by(user, mode = 'view') { accessible_by(user, mode = 'view') {