SailsJs错误。 TypeError:无法读取未定义的属性'属性'
我正在使用sailsjs和mongodb。 我得到错误“TypeError:无法读取属性'未定义的属性”。
这是模型:
UserInterest.js
module.exports = { attributes: { id: { type: 'integer', primaryKey: true }, name: { type: 'string' }, profiles: { collection: 'UserProfile', via: 'interests'} } };
UserProfile.js
module.exports = { attributes : { id : { type : 'string', autoIncrement : true, primaryKey : true }, createdAt : { type : 'datetime' }, updatedAt : { type : 'datetime' }, user : { model : 'User' }, sex : { type : 'integer' }, interests : { collection : "UserInterest", via : "profiles", dominant : true } //Other attributes here } };
我试图得到一个用户configuration文件加载这种方式:
UserProfile.findOne({user : id}) .populate("interests") .exec(function(err, obj) { if (err) { cb(err, null); } else { cb(err, obj); } });
在填充函数中发生错误。 为什么发生这种情况?
经过这个问题苦苦挣扎后,我find了答案。 属性兴趣被重复,风帆有问题。 我消除了重复,留下集合的定义。
- Node.js GraphicsMagick不工作(无效的参数 – – 大小)
- 任何基于JavaScript / jQuery的html数据处理器/美化器?
- Request.body是空的对象
- mongoose – 如何分组和填充?
- 如何在不使用模式configuration参数的情况下使用mongoose在MongoDB模式实例化中的关联数组/对象中执行foreach?
- testing节点,摩卡和柴(应/ bdd语法)
- 发送到节点/快递服务器的数组的访问值
- Docker SIGTERM在使用标志启动时不会被传递到node.js / coffee应用程序
- meteor – 如何重试失败的HTTP请求而不丢失上下文?