<commit_before>import thinky from '../thinky';

let type = thinky.type;

let Point = thinky.createModel('Point', {
    id       : type.string().optional(), // Optional => not specified in bodies but generated by RethinkDB
    name     : String,
    createdAt: type.date().default(new Date()),
    editedAt : Date,
    isRemoved: type.boolean().default(false)
}, {
    enforce_missing: true,
    enforce_extra  : 'remove',
    enforce_type   : 'strict'
});

Point.pre('save', function (next) {
    this.editedAt = new Date();
    next();
});

Point.ensureIndex('name');
Point.ensureIndex('createdAt');
Point.ensureIndex('editedAt');

Point.associate = models => {
    models.Point.hasMany(models.PeriodPoint, 'periodPoints', 'id', 'pointId');
    models.Point.hasMany(models.Article, 'articles', 'id', 'pointId');
    models.Point.hasMany(models.Promotion, 'promotions', 'id', 'pointId');
    models.Point.hasMany(models.Purchase, 'purchases', 'id', 'pointId');
    models.Point.hasMany(models.Reload, 'reloads', 'id', 'pointId');
};

export default Point;
<commit_msg>Point 1:n Article -> Point n:n Article<commit_after>import thinky from '../thinky';

let type = thinky.type;

let Point = thinky.createModel('Point', {
    id       : type.string().optional(), // Optional => not specified in bodies but generated by RethinkDB
    name     : String,
    createdAt: type.date().default(new Date()),
    editedAt : Date,
    isRemoved: type.boolean().default(false)
}, {
    enforce_missing: true,
    enforce_extra  : 'remove',
    enforce_type   : 'strict'
});

Point.pre('save', function (next) {
    this.editedAt = new Date();
    next();
});

Point.ensureIndex('name');
Point.ensureIndex('createdAt');
Point.ensureIndex('editedAt');

Point.associate = models => {
    models.Point.hasMany(models.PeriodPoint, 'periodPoints', 'id', 'pointId');
    models.Point.hasMany(models.Promotion, 'promotions', 'id', 'pointId');
    models.Point.hasMany(models.Purchase, 'purchases', 'id', 'pointId');
    models.Point.hasMany(models.Reload, 'reloads', 'id', 'pointId');
    models.Point.hasAndBelongsToMany(models.Article, 'articles', 'id', 'id');
};

export default Point;

{'fraction_non_alphanumeric': 0.17435424354243542, 'fraction_numerical': 0.00046125461254612545, 'mean_word_length': 4.2139423076923075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '5283070', 'n_tokens_mistral': 703, 'n_tokens_neox': 697, 'n_words': 147}