Skip to content

为什么需要单独把时间戳写出来? #4

@despagito

Description

@despagito
var _getUser = function () {
    /* 用户定义 */
    var userSchema = new Schema({
        username: {type: String, required: true, unique: true},// 用户名
        password: {type: String, required: true},
        email: {type: String},  // 邮箱
        website: {type: String},    // 个人网站
        address: {type: String},    // 所在地点
        github: {type: String}, // github
        signature: {type: String},  // 个人签名
        job: {type: String},        // 职业,
        created_time: {type: Date, default: Date.now}   // 创建时间
    }, {
        //单独写出来的时间戳.
        timestamps: {
            createdAt: 'created_at',
            updatedAt: 'updated_at'
        }
    });
    userSchema.methods.validPassword = function (password) {
        return utils.md5(password, 'base64') == this.password;
    };
    var User = mongoose.model('User', userSchema);
    return Promise.promisifyAll(User);
};

在dbHelper.js文件中.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions