user.js 659 Bytes
/**
 *
 * @author: jiangfeng<jeff.jiang@yoho.cn>
 * @date: 16/8/16
 */

'use strict';

const Model = require('./model');
const md5 = require('md5');

class User extends Model {
    constructor() {
        super('users');
    }

    async init() {
        let count = await this.count({});

        if (count === 0) {
            await this.insert({
                "username": "yoho",
                "password": md5("yoho9646"),
                "role": "1000",
                "state": "1"
            });
        }
    }

    findByUsername(username) {
        return this.findOne({
            username: username
        });
    }
}

module.exports = User;