我知道如何使用聚合,查找或填充从集合中提取数据,这些集合在其架构中具有对另一个集合的单个/多个引用,
但是,如果需要在单个查询中完全对其集合及其引用集合进行更改,我们如何更新此类集合?
模式:
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const tempUserSchema = new mongoose.Schema({
firstName: { type: String },
lastName: { type: String },
emailRegister: { type: String },
dob: { type: Date },
password: { type: String },
active: {type: Boolean, default: false},
deleted: {type: Boolean, default: false},
disabled: {type: Boolean, default: false},
profileImage: {type: String},
phone: {type: Number},
token : {
ref: {
type: mongoose.Schema.Types.ObjectId,
ref: 'tokens'
}
},
skills: [{
ref: {
type: mongoose.Schema.Types.ObjectId,
ref: 'skills'
}
}],
location: {
ref: {
type: mongoose.Schema.Types.ObjectId,
ref: 'userLocations'
}
},
businessDetail: {
ref: {
type: mongoose.Schema.Types.ObjectId,
ref: 'businesses'
}
},
stripDetail : {
ref: {
type: mongoose.Schema.Types.ObjectId,
ref: 'stripeDetails'
}
}
// modifiedOn: [{
// lastBody: { type: String },
// datedOn: { type: Date, default: Date.now }
// }]
}, { timestamps: true });
var users = mongoose.model('tempUsers', tempUserSchema);
module.exports = users;
技能将具有ids
,所以很好,但是我想在其他集合中更新位置并在此处更新_id
中的location