我见过一些与此相关的类似问题,但没有找到答案.
我正在尝试在我的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();
There was an error saving your changes: insertDocument :: caused by ::
11000 E11000 duplicate key error index: site-name.galleries.$key_1 dup
key: { : null } (MongoError)
我不知道我需要改变这个模型以允许我的画廊中的独特slu to直接链接到等等.
解决方法: