I want to create a Category model, which may contain another Category , but having a problem with the link field, so that I can set my current category to myself
Any suggestions for reaching hierarchical categories? Does KeystoneJS Filter As Not Equal? In the other hand, maybe I can set the default link field for it, and it will be like the root ...
My current code is below:
var keystone = require ('keystone'),
Types = keystone.Field.Types;
var PageCategory = keystone.List ('PageCategory', {
map: {name: 'name'},
autokey: {from: 'name', path: 'key'}
});
PageCategory.add ({
name: {type: String, required: true, unique: true},
image: {type: Types.CloudinaryImage, label: "Category Image"},
description: {type: Types.Html, wysiwyg: true},
parent: {type: Types.Relationship, ref: "PageCategory", label: "Parent category"}
});
PageCategory.relationship ({ref: "PageCategory", path: "parent"});
PageCategory.register ();
source share