logo
  • 教程列表
  • SO官方文档
  • Mongoose 图式
    • 创建架构
    • 基本架构
    • 架构方法
    • Schema Statics
    • GeoObjects Schema
    • 节省当前时间和更新时间
  1. StackOverflow 文档
  2. mongoose 教程
  3. Mongoose 图式
  4. 架构方法

架构方法

Created: November-22, 2018

可以在 Schemas 上设置方法,以帮助处理与该模式相关的事情,并使它们井井有条。

userSchema.methods.normalize = function() {
    this.name = this.name.toLowerCase();
};

用法示例:

erik = new User({
    'name': 'Erik',
    'password': 'pass'
});
erik.normalize();
erik.save();
  • Schema Statics
  • 基本架构

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明