mrl*_*sen 1 api mongoose mongodb angularjs
我有以下架构:
var UserSchema = new Schema({
name: String,
email: { type: String, lowercase: true },
projects: [{type: Schema.ObjectId, ref:'Project'}],
//....
}
Run Code Online (Sandbox Code Playgroud)
如何projectId使用添加http.put?
这是我尝试过的事情之一:
$http.put('/api/users/'+User._id, {'projects': project._id});
Run Code Online (Sandbox Code Playgroud)
解决它使用:
$http.put('/api/users/'+User._id, {'projects': User.projects});
在我的更新方法中:
_.extend(user, req.body);
代替
_.merge(user, req.body);
| 归档时间: |
|
| 查看次数: |
883 次 |
| 最近记录: |