{"size": 1052, "ext": "js", "max_stars_repo_path": "app/modal/user.js", "max_stars_repo_name": "shanhaiyige/koa-test", "max_stars_repo_stars_event_min_datetime": "2019-12-09T08:46:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-09T08:34:32.000Z", "max_issues_repo_path": "app/modal/user.js", "max_issues_repo_name": "shanhaiyige/koa-test", "max_issues_repo_issues_event_min_datetime": "2021-07-20T05:59:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T02:56:40.000Z", "max_forks_repo_path": "app/modal/user.js", "max_forks_repo_name": "shanhaiyige/koa-test", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 5, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 21.4693877551, "max_line_length": 69, "alphanum_fraction": 0.4876425856}
let mongoose = require("mongoose");
import BaseDal from './BaseDal'
let Schema = mongoose.Schema;
let UserSchema = new Schema({
    userName: String, // 用户名
    password: String, // 密码
    createTime: {
        type: Date,
        dafault: Date.now()
    },
    updateTime: {
        type: Date,
        dafault: Date.now()
    },
})

UserSchema.pre('save', function (next) {
    if (this.isNew) {
        this.createTime = this.updateTime = Date.now()
    }
    else {
        this.updateTime = Date.now()
    }
    next()
})
class User extends BaseDal{
    constructor() {
        super("user", UserSchema); // 调用父类的constructor(Model, Schema)
    }
    // 此处定义子类的方法

    // findOne (dataArr = {}) {
    //     return new Promise( (resolve, reject) => {
    //         this.model.findOne(dataArr, function (e, docs) {
    //             if (e) {
    //                 reject(e);
    //             } else {
    //                 resolve(docs);
    //             }
    //         })
    //     })
    // }

}

let USER = new User()

export { USER }
