我想为我的流星应用程序创建一个管理表单;在从头开始构建 Ogno Admin 之前,我打算尝试一下 Ogno Admin,但我不确定它是否可以支持我需要的格式的数据。我当前的应用程序数据像这样进入 mongo:
Beaches.insert({
"name": "Entry name",
/* location stored like this so I can use mongo $near queries */
"location": {
"type": "Point",
"coordinates": [-5.0990296,50.110757]
},
/* could be many images, minimum 1 */
"images": [
{
"url": "image1.jpg",
"caption": "Image caption"
}
],
"shortDesc": "A delightful description...",
/* fixed list of attributes stored as objects */
"attributes": {
"attr 1": {
"score": 2,
"text": "attr1 text"
},
我可以编写一个简单的模式来支持上面的不同数组/对象(尤其是位置坐标)吗?它们必须采用方括号格式 [lng, lat] - ogno admin 可以使用它,还是我必须编写自定义管理内容?对我来说,用其他东西构建管理站点并让它为 Meteor 输出 JSON 数据可能会更容易。
使用可能的架构代码进行更新
Beaches = new SimpleSchema({
name: {
type: String,
},
location: {
type: [Object]
},
location.$.type: {
/* how do I force '"type" : "Point" into every entry?
use 'autovalue' with the .clean() function?*/
},
location.$.coordinates: {
/* how do I ensure a [x,y] array in here? */
},
images: {
type: [Object]
},
"images.$.url": {
type: String
},
"images.$.caption": {
type: String
},
attributes: {
type: [Object]
},
/* note that my attributes above are all prefixed with a 'name'
eg. "attr 1" : {}
I'm not sure how to declare these either!
*/
...
});