Mongooose N:M does my db structure it's ok ? How can i handle delete and update in both collections

Hello,i’m creating a project management web app using MEAN Stack and i’m struggling with updating a project and multiple users, when adding/removing participants (users). So i have this two collections, users and projects.
Heres is the users schema:

 name: {type: String, required="true" } ,
    email: {type: String, unique:true, required="true",lowercase:true } ,
    password: {type: String,  required="true"} ,
    projects: [{type: Schema.Types.ObjectId ,required:false,ref:'projects'}]

this is the projects schema:

   name:{type: String, required:true,unique:true},
    description: {type: String, required:true},
    creator: {type: Schema.Types.ObjectId,required:false,ref:'users'},
    lastEditor:{type: Schema.Types.ObjectId,required:false,ref:'users'},
    participants:[{type: Schema.Types.ObjectId ,required:false,ref:'users'}],
    files: [{type: Schema.Types.ObjectId,required:false, ref:'files'}]

I’m thinking about the next aproach:
when editting the project i’m using an array of users objects to add/remove these users, so when i submit the form i get the whole project object in req.body i’m thinking about using a foraeach to push the users _id into participants array from the users object, but here is where i got lost, i don’t know how to push the project id into all the users from the given _id in the foreach loop. deleting i thinks is about the same way, splicing the _id from participants array it should remove the project from user. i’ll apreciate all your help with this

If you’re trying to update array fields I would suggest looking at the array update operators here. I don’t recommend doing the looping/splicing and such using javascript, you should pass the work load on to mongodb. To be honest it might be a better idea to model the data differently. You essentially have to manage data in two places every time a participant is added/removed from a project.

Why not remove the projects reference from the user model, and when ever you query a user you can fetch any projects where they are included in the participants array?