Here is my document schema:
var UserSchema = new mongoose.Schema({
username: {type: String, lowercase: true, unique: true},
email: {type:String, unique: true},
currentSquads: [{seriesId: String, squad: [String]}]
});
Given a _id
(for the UserSchema document), seriesId
and squad
: I would like to update the user document with the new squad if the seriesId already exists in the currentSquads
array, otherwise add a new object in the currentSquad
array.
What is the best way to do this in Mongoose?