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

'use strict';

import Model from './model';
import md5 from '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
        });
    }
}

export default User;