问题描述
我要在Keystone 5项目中添加一个名为“ tourlocation”的列表。在我的mongo数据库中,我的tourlocations集合有一个名为“ coordinates”的对象,具有两个值:“ lat”和“ long”。示例:
"coordinates" : {
"lat" : 53.343761,"long" : -6.24953
},
在先前的梯形校正版本中,我可以这样定义我的游览位置列表坐标对象:
coordinates: {
lat: {
type: Number,noedit: true
},long: {
type: Number,noedit: true
}
现在不幸的是,当我尝试以这种方式定义列表时,会出现错误:'tourlocation.coordinates' field doesn't specify a valid type. (tourlocation.coordinates.type is undefined)'
有什么方法可以在梯形校正5中表示对象?
解决方法
@Alex Hughes,我相信您的错误会显示“类型”,您可能需要这样添加它
keystone.createList('User',{
fields: {
name: { type: Text },// Look at the type "Text" even in the MongoDB you can choose the type but it will be better to choose it here from the beginning.
email: { type: Text },},});
请注意,KeystoneJS的版本5不支持noedit: true
。
有关更多信息,请参见此页面https://www.keystonejs.com/blog/field-types#core-field-types