Answer the question
In order to leave comments, you need to log in
Automatic update of many-to-many relationships in MongoDB (Mongoose) ?
There are two data models with a many-to-many relationship, how to correctly implement a change in relationships when updating 1 model?
var User = new mongoose.Schema({
venue: {
type: [mongoose.Schema.Types.ObjectId],
ref: 'Site'
}
}
var Site = new mongoose.Schema({
user: {
type: [mongoose.Schema.Types.ObjectId],
ref: 'User'
}
}
Answer the question
In order to leave comments, you need to log in
You have at least some nonsense with the syntax. If you format your code, you get something very strange:
bot.on('message', httpGet(msg))
httpGet(
function(msg) {
var chatId = msg.chat.id;
console.log(msg);
bot.sendMessage(chatId, "Привет11", {
caption: "I'm a bot!"
});
return chatId;
}.then(sendM(chatId), function(chatId) {
return chatId;
})
);
Search by ref and update the record(s) of the second model when the first one changes. There is a mongoose-relationship
plugin for mongoose
IMHO, using mongoose with its schemas is not justified in most cases.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question