attributes: {
username: {
type: 'email', // validated by the ORM
required: true
},
password: {
type: 'string',
required: true
},
profile: {
firstname: 'string',
lastname: 'string',
photo: 'string',
birthdate: 'date',
zipcode: 'integer'
},
followers: 'array',
followees: 'array',
blocked: 'array'
}
我目前注册用户,然后在注册后更新个人资料信息。如何将配置文件数据添加到此模型?
我在其他地方读到 push 方法应该可以工作,但它没有。我收到此错误:TypeError: Object [object Object] has no method 'push'
Users.findOne(req.session.user.id).done(function(error, user) {
user.profile.push({
firstname : first,
lastname : last,
zipcode: zip
})
user.save(function(error) {
console.log(error)
});
});