【问题标题】:Undefined 'model' property of Keystonejs List object [closed]Keystonejs List对象的未定义“模型”属性[关闭]
【发布时间】:2016-12-07 18:03:47
【问题描述】:

我用一个非常简单的(国家)列表创建了一个示例,并根据此处的说明创建了 api 路由:https://gist.github.com/JedWatson/9741171

server.js:

app.get('/api/countries', keystone.middleware.api, routes.api.countries.list);

routes/api/countries.js:

import keystone from 'keystone';

export function list(req, res) {
  keystone.List('Country').model.find((err, items) => {
    if (err) return res.apiError('database error', err);

    res.apiResponse({
      countries: items
    });
  });
}

我收到错误Cannot read property 'find' of undefined,List 对象存在但它没有model 属性。有人知道为什么吗? keystone 管理界面按预期工作,并且数据库中有多个对象。

【问题讨论】:

    标签: keystonejs


    【解决方案1】:

    问题是我使用了keystone.List(大写)而不是keystone.list。希望这个答案能帮助其他人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-21
      • 1970-01-01
      • 2023-04-09
      • 2016-08-03
      • 2012-08-26
      相关资源
      最近更新 更多