<commit_before>import {
    DELETE,
    UPDATE,
} from './constants.js';

/**
 * A thin wrapper around an entity to record mutations.
 */
const Entity = class Entity {
    constructor(manager, props) {
        Object.assign(this, {manager}, props);
        this._fieldNames = Object.keys(props);
    }

    getId() {
        return this[this.manager.schema.idAttribute];
    }

    toPlain() {
        const obj = {};
        this._fieldNames.forEach((fieldName) => {
            obj[fieldName] = this[fieldName];
        });
        return obj;
    }

    /**
     * Records a mutation to the Entity instance for a single
     * field value assignment.
     * @param {string} propertyName - name of the property to set
     * @param {*} value - value assigned to the property
     * @return {undefined}
     */
    set(propertyName, value) {
        this.update({[propertyName]: value});
    }

    /**
     * Records a mutation to the Entity instance for multiple field value assignments.
     * @param  {Object} mergeObj - an object that will be merged with this instance.
     * @return {undefined}
     */
    update(mergeObj) {
        Object.assign(this, mergeObj);
        this.manager.mutations.push({
            type: UPDATE,
            payload: {
                idArr: [this.getId()],
                updater: mergeObj,
            },
        });
    }

    /**
     * Records the Entity to be deleted.
     * @return {undefined}
     */
    delete() {
        this.manager.mutations.push({
            type: DELETE,
            payload: [this.getId()],
        });
    }<commit_msg>Store reference to manager in _manager in Entity<commit_after>import {
    DELETE,
    UPDATE,
} from './constants.js';

/**
 * A thin wrapper around an entity to record mutations.
 */
const Entity = class Entity {
    constructor(manager, props) {
        Object.assign(this, {_manager: manager}, props);
        this._fieldNames = Object.keys(props);
    }

    getId() {
        return this[this._manager.schema.idAttribute];
    }

    toPlain() {
        const obj = {};
        this._fieldNames.forEach((fieldName) => {
            obj[fieldName] = this[fieldName];
        });
        return obj;
    }

    /**
     * Records a mutation to the Entity instance for a single
     * field value assignment.
     * @param {string} propertyName - name of the property to set
     * @param {*} value - value assigned to the property
     * @return {undefined}
     */
    set(propertyName, value) {
        this.update({[propertyName]: value});
    }

    /**
     * Records a mutation to the Entity instance for multiple field value assignments.
     * @param  {Object} mergeObj - an object that will be merged with this instance.
     * @return {undefined}
     */
    update(mergeObj) {
        Object.assign(this, mergeObj);
        this._manager.mutations.push({
            type: UPDATE,
            payload: {
                idArr: [this.getId()],
                updater: mergeObj,
            },
        });
    }

    /**
     * Records the Entity to be deleted.
     * @return {undefined}
     */
    delete() {
        this._manager.mutations.push({
            type: DELETE,
            payload: [this.getId()],
        });
    }
{'fraction_non_alphanumeric': 0.12060456508328192, 'fraction_numerical': 0.0, 'mean_word_length': 1.8826666666666667, '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': '1819732', 'n_tokens_mistral': 914, 'n_tokens_neox': 890, 'n_words': 252}