Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否有方法从Node.js和Mongoose中现有的MongoDB模型声明新的MongoDB模型?_Node.js_Mongodb_Mongoose - Fatal编程技术网

是否有方法从Node.js和Mongoose中现有的MongoDB模型声明新的MongoDB模型?

是否有方法从Node.js和Mongoose中现有的MongoDB模型声明新的MongoDB模型?,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我有一个用Mongoose定义的现有模型,如下所示 var ProductSchema = new Schema({ name: {type: Array, default: []}, userId: {type: Schema.Types.ObjectId, ref: 'User'}, //Admin assignee: {type: Schema.Types.ObjectId, ref: 'User'}, ... // has more than 50 propert

我有一个用Mongoose定义的现有模型,如下所示

var ProductSchema = new Schema({
  name: {type: Array, default: []},
  userId: {type: Schema.Types.ObjectId, ref: 'User'},

  //Admin
  assignee: {type: Schema.Types.ObjectId, ref: 'User'},

  ... // has more than 50 properties

  flyerProvided: Boolean,
  lockboxOrdered: Boolean,
  lockboxTrackingInformation: String
}, {
  toObject: {
    virtuals: true
  },
  toJSON: {
    virtuals: true
  }
});
我想要实现的是定义一个新的Mongoose模型来存储删除的产品。 因此,我希望将产品移动到
ArchivedProducts
集合,而不是从产品集合中删除产品

但是,除了复制ProductSchema的所有属性(超过56个)之外,有没有一种简单的方法来使用或扩展产品模型