keystonejs中的模型关系导致服务器上的错误

时间:2014-08-06 00:23:39

标签: node.js heroku keystonejs

我有一个keystonejs应用程序,并在本地和服务器上使用相同的mongohq数据库。该应用程序运行正常,但只要我将一些数据添加到指定关系的集合中,就会导致应用程序在服务器上崩溃。使用相同的数据库在本地仍然可以正常工作。

我创建了一个名为Admin的自定义字段类型,这似乎是问题,但仅限于服务器。

var keystone = require('keystone'),
Types = keystone.Field.Types;

var Group = new keystone.List('Group');

Group.add({
  name: { type: String, required: true, initial: true },
    createdAt: { type: Date, default: Date.now },
  //groupId: { type: Types.Admin, required: true, initial: true, default: 'placeholder' }
});

Group.defaultColumns = 'name';
Group.register();

ERR

2014-08-06T00:19:55.649442+00:00 heroku[web.1]: State changed from crashed to starting
2014-08-06T00:20:01.383817+00:00 app[web.1]: 
2014-08-06T00:20:01.387982+00:00 app[web.1]: TypeError: Cannot read property 'note' of undefined
2014-08-06T00:20:01.387993+00:00 app[web.1]:   at Function._.each._.forEach (/app/node_modules/underscore/underscore.js:82:22)
2014-08-06T00:20:01.387988+00:00 app[web.1]:   at List.<anonymous> (/app/node_modules/keystone/lib/list.js:193:5)
2014-08-06T00:20:01.387994+00:00 app[web.1]:   at List.add (/app/node_modules/keystone/lib/list.js:206:4)
2014-08-06T00:20:01.387986+00:00 app[web.1]:   at List.field (/app/node_modules/keystone/lib/list.js:296:14)
2014-08-06T00:20:01.387999+00:00 app[web.1]:   at Module.load (/app/node_modules/keystone/node_modules/cloudinary/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
2014-08-06T00:20:01.387987+00:00 app[web.1]:   at List.<anonymous> (/app/node_modules/keystone/lib/list.js:202:16)
2014-08-06T00:20:01.387990+00:00 app[web.1]:   at List.<anonymous> (/app/node_modules/keystone/lib/list.js:188:6)
2014-08-06T00:20:01.387991+00:00 app[web.1]:   at List.<anonymous> (/app/node_modules/keystone/lib/list.js:232:5)
2014-08-06T00:20:01.387997+00:00 app[web.1]:   at Module._compile (module.js:456:26)
2014-08-06T00:20:01.387995+00:00 app[web.1]:   at Object.<anonymous> (/app/models/Group.js:11:7)
2014-08-06T00:20:01.388005+00:00 app[web.1]:   at /app/node_modules/keystone/index.js:212:34
2014-08-06T00:20:01.388006+00:00 app[web.1]:   at Array.forEach (native)
2014-08-06T00:20:01.387998+00:00 app[web.1]:   at Object.Module._extensions..js (module.js:474:10)
2014-08-06T00:20:01.388003+00:00 app[web.1]:   at require (module.js:380:17)
2014-08-06T00:20:01.388019+00:00 app[web.1]: 
2014-08-06T00:20:01.388009+00:00 app[web.1]:   at [object Object].Keystone.import (/app/node_modules/keystone/index.js:221:9)
2014-08-06T00:20:01.388002+00:00 app[web.1]:   at Module.require (module.js:364:17)
2014-08-06T00:20:01.388001+00:00 app[web.1]:   at Function.Module._load (module.js:312:12)
2014-08-06T00:20:01.388016+00:00 app[web.1]:   at Function.Module.runMain (module.js:497:10)
2014-08-06T00:20:01.388012+00:00 app[web.1]:   at Object.Module._extensions..js (module.js:474:10)
2014-08-06T00:20:01.388014+00:00 app[web.1]:   at Module.load (module.js:356:32)
2014-08-06T00:20:01.388010+00:00 app[web.1]:   at Object.<anonymous> (/app/keystone.js:35:16)
2014-08-06T00:20:01.388015+00:00 app[web.1]:   at Function.Module._load (module.js:312:12)
2014-08-06T00:20:01.388007+00:00 app[web.1]:   at doImport (/app/node_modules/keystone/index.js:199:28)
2014-08-06T00:20:01.388011+00:00 app[web.1]:   at Module._compile (module.js:456:26)
2014-08-06T00:20:01.388018+00:00 app[web.1]:   at node.js:906:3
2014-08-06T00:20:01.388017+00:00 app[web.1]:   at startup (node.js:119:16)
2014-08-06T00:20:02.692382+00:00 heroku[web.1]: Process exited with status 8
2014-08-06T00:19:58.434784+00:00 heroku[web.1]: Starting process with command `node keystone.js`
2014-08-06T00:20:02.701927+00:00 heroku[web.1]: State changed from crashed to starting
2014-08-06T00:20:02.701002+00:00 heroku[web.1]: State changed from starting to crashed

0 个答案:

没有答案