我想在我稍后传递给 List.add 的模式对象中的 keystone.List 构造函数中使用从 autokey 插件生成的相同值。
这更准确地说是我想要做的:
var Thing = new keystone.List('Thing', {
autokey: { path: 'slug', from: 'title', unique: true }
});
Thing.add({
image: {
type: Types.LocalFile,
dest: 'public/images/things/'+Thing.slug,
prefix: '/images/things/'+Thing.slug+'/',
format: function( ThingDoc, file ) { return '<img src="/images/things/'+ThingDoc.slug+'/'+file.filename+'" style="max-width:300px" />' }
}
});
所以这当然行不通。我怎样才能在我的模式中重新使用自动键入的 slug 值?
顺便说一句,引用在“格式”函数中起作用,因为当调用该函数时,它可以通过实例化模型提取存储的值。