Schema.prototype.pick()
Parameters
paths «Array» list of paths to pick
[options] «Object» options to pass to the schema constructor. Defaults to
this.options
if not set.
Returns:
- «Schema»
Returns a new schema that has the picked paths
from this schema.
This method is analagous to Lodash’s pick()
function for Mongoose schemas.
Example:
const schema = Schema({ name: String, age: Number });
// Creates a new schema with the same `name` path as `schema`,
// but no `age` path.
const newSchema = schema.pick(['name']);
newSchema.path('name'); // SchemaString { ... }
newSchema.path('age'); // undefined
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .