34 lines
814 B
JavaScript
34 lines
814 B
JavaScript
|
const Model = require("flitter-orm/src/model/Model");
|
||
|
const { ObjectId } = require("mongodb");
|
||
|
|
||
|
//custom
|
||
|
const NodeData = require("./NodeData.model");
|
||
|
|
||
|
/*
|
||
|
* Node Model
|
||
|
* -------------------------------------------------------------
|
||
|
* Put some description here!
|
||
|
*/
|
||
|
class Node extends Model {
|
||
|
static get schema() {
|
||
|
// Return a flitter-orm schema here.
|
||
|
return {
|
||
|
Type: String,
|
||
|
Value: NodeData,
|
||
|
PageId: ObjectId,
|
||
|
CreatedAt: { type: Date, default: () => new Date() },
|
||
|
UpdatedAt: { type: Date, default: () => new Date() },
|
||
|
CreatedUserId: { type: ObjectId },
|
||
|
UpdateUserId: { type: ObjectId }
|
||
|
};
|
||
|
}
|
||
|
|
||
|
// Static and instance methods can go here
|
||
|
get page() {
|
||
|
const Page = this.model.get("api:Page")
|
||
|
return this.belongs_to_one(Page, "PageId", "_id")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = exports = Node;
|