Skip to content

class 语法糖 #2

Description

@plh97
function authUser() {};
authUser.prototype.save = function(data) {
    return new authUserModel(data).save();
};

authUser.prototype.update = function(data) {
    let condition = {
        login: data.login
    };
    return authUserModel.update(condition, data).exec();
};

authUser.prototype.find = function(condition) {
    return authUserModel.find(condition).exec();
};

module.exports = new authUser();

用class写舒服多了

class authUser {
    save(data) {
        return new authUserModel(data).save();
    }

    update(data) {
        return authUserModel.update({
            login: data.login
        }, data).exec();
    }

    find(condition) {
        return authUserModel.find(condition).exec();
    }
}

module.exports = new authUser();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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