<commit_before>/** @module authr-nedb */

var Sequelize = require('sequelize');
var moment = require('moment');
var bcrypt = require('bcrypt');
var crypto = require('crypto');

/**
 * Represents a new Adapter instance for authr-sql.
 * @class
 * @param {object} config - Authr config object
 */

function Adapter(config, callback) {
    var self = this;
    this.config = config;
    sqlconfig = {
        port: config.db.port,
        dialect: config.db.type,
        storage: config.db.name,
        logging: false
    };
    this.db = new Sequelize(config.db.database_name, config.db.username, config.db.password, sqlconfig);
    this.connect(function (err) {
        self.buildUserModel(function () {
            callback();
        });
    });
}

Adapter.prototype.connect = function (callback) {
    this.db.authenticate().complete(function (err) {
        callback(err);
    });
};

Adapter.prototype.disconnect = function(callback){
    // Just return the callback because sequelize doesn't seem to require a disconnect
  callback();  
};

/**
 * Function used to build user model<commit_msg>added check for constructor callback to prevent errors when it does not exist<commit_after>/** @module authr-nedb */

var Sequelize = require('sequelize');
var moment = require('moment');
var bcrypt = require('bcrypt');
var crypto = require('crypto');

/**
 * Represents a new Adapter instance for authr-sql.
 * @class
 * @param {object} config - Authr config object
 */

function Adapter(config, callback) {
    var self = this;
    this.config = config;
    sqlconfig = {
        port: config.db.port,
        dialect: config.db.type,
        storage: config.db.name,
        logging: false
    };
    this.db = new Sequelize(config.db.database_name, config.db.username, config.db.password, sqlconfig);
    this.connect(function (err) {
        self.buildUserModel(function () {
            if(callback){
                callback();
            }
            
        });
    });
}

Adapter.prototype.connect = function (callback) {
    this.db.authenticate().complete(function (err) {
        if(callback){
            callback(err);
        }
    });
};

Adapter.prototype.disconnect = function(callback){
    // Just return the callback because sequelize doesn't seem to require a disconnect
  callback();  
};

/**
 * Function used to build user model
{'fraction_non_alphanumeric': 0.13067458633856596, 'fraction_numerical': 0.0, 'mean_word_length': 2.7788461538461537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '840278', 'n_tokens_mistral': 680, 'n_tokens_neox': 672, 'n_words': 179}