Schema.prototype.add()
Parameters
obj «Object|Schema» plain object with paths to add, or another schema
[prefix] «String» path to prefix the newly added paths with
Returns:
- «Schema» the Schema instance
Adds key path / schema type pairs to this schema.
Example:
const ToySchema = new Schema();
ToySchema.add({ name: 'string', color: 'string', price: 'number' });
const TurboManSchema = new Schema();
// You can also `add()` another schema and copy over all paths, virtuals,
// getters, setters, indexes, methods, and statics.
TurboManSchema.add(ToySchema).add({ year: Number });
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .