Keystonejs List对象的未定义'model'属性

Seb*_*ian 3 keystonejs

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

server.js:

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

路线/ 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
    });
  });
}
Run Code Online (Sandbox Code Playgroud)

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

Seb*_*ian 6

问题是我使用keystone.List(大写)而不是keystone.list.希望这个答案可以帮助别人.