Cod*_*onk 3 javascript mongoose mongodb keystonejs
我见过一些与此相关的类似问题,但没有找到答案.
我正在尝试在我的Keystone项目中创建一个类似于帖子的图库,其中将有一个图库列表,其中包含一组选定图像的图库:
var keystone = require('keystone'),
Types = keystone.Field.Types;
/**
* Gallery Model
* =============
*/
var Gallery = new keystone.List('Gallery', {
map: { name: 'name' },
autokey: { path: 'slug', from: 'name', unique: true }
});
Gallery.add({
name: { type: String, required: true},
published: {type: Types.Select, options: 'yes, no', default: 'no', index: true},
publishedDate: { type: Types.Date, index: true, dependsOn: { published: 'yes' } },
description: { type: String },
heroImage : { type: Types.Relationship, ref: 'Image' },
images : { type: Types.Relationship, ref: 'Image', many: true }
});
Gallery.defaultColumns = 'title, published|20%, publishedDate|20%';
Gallery.register();
Run Code Online (Sandbox Code Playgroud)
我能够成功创建一个库 - 但任何后续的画廊都会抛出错误:
保存更改时出错:insertDocument ::由:: 11000引起E11000重复键错误索引:site-name.galleries.$ key_1 dup key:{:null}(MongoError)
我不知道我需要改变这个模型以允许我的画廊中的独特slu to直接链接到等等.
| 归档时间: |
|
| 查看次数: |
1015 次 |
| 最近记录: |