我是Mongodb的新手让我说我需要在3个不同的_789350中插入 3 documents
例如,假设我有一个 department
, students
和 department_membership
集合 . 当部门主管将一个 student
添加到 department
时,所以我需要插入文件的时候
{_ id:123,name:“st_name”,email:“test@gmail.com”}
在 student
集合中,
{_ id:2356,dept_id:12,added_by_whom_id:253,student_id:123}
在 department
集合中
{_ id:13111,dept_id:12,student:{_ id:123,name:“st_name”}}
在 department membership
集合中
我想要的是要么在相应的集合中插入所有文档,否则它应该失败,如何处理?