Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 是否在keystone.js管理UI中显示来自其他模型(集合)的字段?_Node.js_Mongodb_Mongoose_Keystonejs - Fatal编程技术网

Node.js 是否在keystone.js管理UI中显示来自其他模型(集合)的字段?

Node.js 是否在keystone.js管理UI中显示来自其他模型(集合)的字段?,node.js,mongodb,mongoose,keystonejs,Node.js,Mongodb,Mongoose,Keystonejs,我有两种型号 /** * Page Model * ============= */ var Page = new keystone.List('Page'); Page.add({ name: { type: String, required: true }, pid: { type: String, required: true , default:"123" }, phone: { type: String }, keyword : {type:

我有两种型号

/**
 * Page Model
 * =============
 */

var Page = new keystone.List('Page');

Page.add({
    name: { type: String, required: true },
    pid: { type: String, required: true , default:"123" },
    phone: { type: String },
    keyword : {type: Types.Relationship, ref: 'Keyword' , many: true},
    searchvol : {type: Types.Relationship, ref: 'Keyword' , many: true},
    pageType: { type: Types.Select, options: [
        { value: 'message', label: 'Just leaving a message' },
        { value: 'question', label: 'I\'ve got a question' },
        { value: 'other', label: 'Something else...' }
    ] },
    createdAt: { type: Date, default: Date.now }
});

Page.relationship({ path: 'keywords', ref: 'Keyword',    refPath: 'keyword' });
Page.relationship({ path: 'keywords', ref: 'Keyword',    refPath: 'searchvol' });
关键词模型

/**
 * Keyword Model
 * =============
 */

var Keyword = new keystone.List('Keyword');

Keyword.add({
    //name: { type: String, required: true },
    searchvol: { type: String },
    keywordType: { type: Types.Select, options: [
        { value: 'message', label: 'brand' },
        { value: 'question', label: 'exact match' },
        { value: 'other', label: 'Something else...' }
    ] },
    createdAt: { type: Date, default: Date.now }
});
我想在管理界面中包括搜索卷,以便我可以使用它进行排序和筛选

然而,它似乎只能包含name字段,如果我删除该字段,它只显示id

所以,解决这个问题的唯一方法是构建一个自定义crud接口来处理我的“连接”,或者有一种方法可以使它与当前设置一起工作

这里是文档的链接,我在这里找到了一些关于如何执行此操作的详细信息。

@RaedMarji,Keystone始终使用to
name
字段来显示引用的关系。但是,在类似您的情况下,当您没有
name
字段时,您可以映射现有字段,使其与模型的名称类似

只需按如下方式更新列表定义:

var Keyword = new keystone.List('Keyword', {
    map: { name: 'searchvol' }
});

我明白这一点,但是如果我想显示其他集合中的多个值,比如名称、搜索文本和类型,该怎么办。都属于同一个id。对不起,你的问题不清楚。我完全理解您想要“在管理UI中包含搜索卷”的内容。不幸的是,目前不可能这样做。我相信目前还有另一个相关问题有待解决。是的,我理解你的困惑,而且似乎没有实现这一点。在我看来这很奇怪。然而,我认为它可以做同样的方式名称已经做。也许有人可以调查一下。我会试着自己看一看,也许我能解决。