<commit_before>'use strict';

// Exports
export default (BaseModel) => {
    class Model extends BaseModel {
        $beforeValidate(...args) {
            const schema = super.$beforeValidate(...args);
            if (this.constructor.timestamps && schema && schema.properties) {
                if (this.constructor.camelCase && (!schema.properties.createdAt || !schema.properties.updatedAt)) throw new Error(`Invalid jsonSchema for model '${this.constructor.name}'. Add 'createdAt' and 'updatedAt' to the schema to use timestamps`);
                else if (!this.constructor.camelCase && (!schema.properties.created_at || !schema.properties.updated_at)) throw new Error(`Invalid jsonSchema for model '${this.constructor.name}'. Add 'created_at' and 'updated_at' to the schema to use timestamps`);
            }
            return schema;
        }
        $beforeInsert(...args) {
            const out = super.$beforeInsert(...args);
            if (this.constructor.timestamps) {
                const datetime = new Date().toISOString();
                if (this.constructor.camelCase) {
                    this.createdAt = datetime;
                    this.updatedAt = datetime;
                }
                else {
                    this.created_at = datetime;
                    this.updated_at = datetime;
                }
            }
            return out;
        }

        $beforeUpdate(...args) {
            const out = super.$beforeUpdate(...args);
            if (this.constructor.timestamps) {
                const datetime = new Date().toISOString();
                if (this.constructor.camelCase) this.updatedAt = datetime;
                else this.updated_at = datetime;
            }
            return out;
        }<commit_msg>Reverse order of $beforeInsert and $beforeUpdate lifecycle hooks<commit_after>'use strict';

// Exports
export default (BaseModel) => {
    class Model extends BaseModel {
        $beforeValidate(...args) {
            const schema = super.$beforeValidate(...args);
            if (this.constructor.timestamps && schema && schema.properties) {
                if (this.constructor.camelCase && (!schema.properties.createdAt || !schema.properties.updatedAt)) throw new Error(`Invalid jsonSchema for model '${this.constructor.name}'. Add 'createdAt' and 'updatedAt' to the schema to use timestamps`);
                else if (!this.constructor.camelCase && (!schema.properties.created_at || !schema.properties.updated_at)) throw new Error(`Invalid jsonSchema for model '${this.constructor.name}'. Add 'created_at' and 'updated_at' to the schema to use timestamps`);
            }
            return schema;
        }
        $beforeInsert(...args) {
            if (this.constructor.timestamps) {
                const datetime = new Date().toISOString();
                if (this.constructor.camelCase) {
                    this.createdAt = datetime;
                    this.updatedAt = datetime;
                }
                else {
                    this.created_at = datetime;
                    this.updated_at = datetime;
                }
            }
            return super.$beforeInsert(...args);
        }

        $beforeUpdate(...args) {
            if (this.constructor.timestamps) {
                const datetime = new Date().toISOString();
                if (this.constructor.camelCase) this.updatedAt = datetime;
                else this.updated_at = datetime;
            }
            return super.$beforeUpdate(...args);
        }
{'fraction_non_alphanumeric': 0.11384876805437553, 'fraction_numerical': 0.0, 'mean_word_length': 1.8165869218500796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6068519', 'n_tokens_mistral': 891, 'n_tokens_neox': 866, 'n_words': 211}