I have the following schemaconst TandaSchema = new Schema ({name: {type: String,required: true},secretary: {type: Schema.Types.ObjectId,ref: 'users',required: true},members: [{user : {type: Schema.Types.ObjectId, ref : 'users'},status: {type: String, default: 'waiting'},}],.....}Am I declaring members the correct way? I'm having an issue calling the array method .push on the members after I find a document. The program jumps to the catch block when tanda.members.push is called. Thank you for any help and sorry for formatting errors.Tanda.find({registrationCodes: {$elemMatch: {code: 'abc', email: '[johndoe@gmail.com](mailto:johndoe@gmail.com)'}}}).then(tanda => {const newMember = {user: req.body.newMemberID,status: 'waiting'}tanda.members.push(newMember);tanda.save();return res.json(tanda);}).catch.....
Submitted February 28, 2019 at 01:49AM by TalkingToMyselff
No comments:
Post a Comment