我有一个名为“任务”的集合 .

const TaskSchema = new mongoose.Schema({
 task_name:{
    type: String,
    required: true,
    minlength: 1,
    unique: true,
},
task_category: String,
task_xpreward: Number,
task_completed: Boolean,
task_difficulty: Number,  //1 = Easy, 2 = Medium, 3 = Hard, 4 = Very Hard, 5 
= Impossible
task_solution: String,
task_city : String
});

这就像一个用户可以选择的任务池 . 当用户单击某个任务(声明它)时 .

它应该被克隆到另一个名为“Taskuser”的集合中 . 此集合的行为类似于分配给某个userId的任务池 .

const TaskuserSchema = new mongoose.Schema({
task_name:{
    type: String,
    required: true,
    minlength: 1,
    unique: true,
},
userId: {
    type: mongoose.Schema.Types.ObjectId,
    required: true,
  },
task_category: {
    type : String,
    required : true,
},
task_xpreward: {
    type : Number,
    required : true,
},
task_completed: {
    type : Boolean,
    required : true,
},
task_difficulty: {
    type : Number,
    required : true,
},                     //1 = Easy, 2 = Medium, 3 = Hard, 4 = Very Hard, 5 = Impossible
task_city : {
    type : String,
    required : true,
},
task_solution : String //Oplossing van de task, API gaat hierop checken
});

我怎样才能做到这一点,当有 PUT/POST 调用将任务分配给他的池时 . 某个任务将使用来自点击它的用户的UserId克隆到集合"Taskuser"中?我只需要知道如何从1个集合中克隆文档并将其放入另一个集合中 .