我创建了56个类别,当我想要创建一个新帖子时,我要选择我想要的类别只有50个。其他6个没有出现,你甚至无法选择它们它不喜欢的类别的名称。
我如何解决这个问题?
这是模型
var keystone = require('keystone');
var Types = keystone.Field.Types;
/**
* Post Model
* ==========
*/
var Post = new keystone.List('Post', {
map: { name: 'title' },
autokey: { path: 'slug', from: 'title', unique: true },
});
Post.add({
title: { type: String, required: true },
categories: { type: Types.Relationship, ref: 'PostCategory', many: true},// <- This is Shows only 50 instead of 56!
state: { type: Types.Select, options: 'draft, published, archived', default: 'published', index: true, required: true },
publishedDate: { type: Types.Date, index: true, default: Date.now, required: true, dependsOn: { state: 'published' } },
mainPDF: { type: Types.LocalFile, dest: 'public/pdf/mainpdf'},
pronunciations: { type: Types.LocalFile, dest: 'public/pdf/pronunciations'},
answers: { type: Types.LocalFile, dest: 'public/pdf/answers' },
}}
});
Post.schema.virtual('content.full').get(function () {
return this.content.extended || this.content.brief;
});
Post.defaultColumns = 'title,categories|20%, publishedDate|20%';
Post.register();
答案 0 :(得分:1)
您可以修改/node_modules/keystone/admin/api/list.js
文件,并注释掉case: 'autocomplete'
行(第26行)下的前三行。这仅适用于Keystone 3;我不知道这是一个问题还是Keystone 4,或者如果它是如何解决它(这个文件位于不同的位置,我还没有找到它。)新代码应如下所示:
case 'autocomplete':
// var limit = Number(req.query.limit) || 50;
// var page = Number(req.query.page) || 1;
// var skip = limit * (page - 1);
如果您从package.json
下载Keystone在线(Heroku,Digital Ocean,Amazon S3),我认为这是不可能的,除非您创建一个Keystone 3分支并在NPM上托管它