KeystoneJS模型中的猫鼬模式类型 [英] Mongoose schema types in KeystoneJS models
本文介绍了KeystoneJS模型中的猫鼬模式类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var keystone = require('keystone'),
Types = keystone.Field.Types;
var LeaderboardEntry = new keystone.List('leaderboardEntry', {
autokey: { path: 'slug', from: 'publicKey playername', unique: false }
});
LeaderboardEntry.add({
publicKey: { type: String, required: true, noedit: true },
playername: { type: String, required: true },
playerid: { type: String },
points: { type: Number, required: true },
/*data: { type: Mixed, required: false, unique: false },*/
publishedDate: { type: Types.Date }
});
字段data
的类型必须为混合,但不幸的是,没有匹配的KeystoneJS类型.
The field data
needs to be of type Mixed but unfortunately there is not a matching KeystoneJS type.
有什么想法可以在keystone.List对象中完成此操作吗?
Any ideas how this can be done within a keystone.List object?
推荐答案
前一段时间,我遇到了同样的问题,并遇到了 Twitter帖子 ..它不会显示在管理界面中,但是可以通过这种方式添加Mongoose字段类型.
A while back I ran into the same issue and ran across this Twitter post .. It won't show up in the admin UI, but it's possible to add a Mongoose field type this way.
在上面的代码之后添加此代码:
Add this after your code above:
LeaderboardEntry.schema.add({ data: mongoose.Schema.Types.Mixed });
这篇关于KeystoneJS模型中的猫鼬模式类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文