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

  • 關於本站
  • 免責聲明