<commit_before>const { Schema } = require('mongoose');

const generateId = require('../../lib/id');
const connection = require('../').createConnection();

const seriesSchema = new Schema({
  _id: {
    type: String,
    index: true,
    unique: true,
    required: true,
    default: generateId,
  },
  title: {
    type: String,
    index: true,
  },
  description: String,
  url: String,
  image: String,
  authors: {
    type: [String],
    default: [],
  },
  publisher: String,
  asins: {
    type: [String],
    default: [],
  },
}, {
  timestamps: true,
});

class SeriesClass {
  static async firstOrCreate(query, doc = query) {
    const series = await this.findOne(query);
    if (series) { return { series, newRecord: false }; }
    return { series: await this.create(doc), newRecord: true };
  }

  addAsinIfNotIncludes(asin) {
    if (!this.asins.includes(asin)) { this.asins.push(asin); }
    return this;
  }

  mergeAuthors(authors) {
    for (const author of authors) {
      if (!this.authors.includes(author)) { this.authors.push(author); }
    }
    return this;
  }
}
seriesSchema.loadClass(SeriesClass);

const Series = connection.model('Series', seriesSchema);
Series.shcema = seriesSchema;

module.exports = Series;
<commit_msg>chnage entity of book<commit_after>const { Schema } = require('mongoose');

const generateId = require('../../lib/id');
const connection = require('../').createConnection();

const seriesSchema = new Schema({
  _id: {
    type: String,
    index: true,
    unique: true,
    required: true,
    default: generateId,
  },
  title: {
    type: String,
    index: true,
  },
  description: String,
  bundleUrl: String,
  listUrl: String,
  image: String,
  authors: {
    type: [String],
    default: [],
  },
  publisher: String,
  asins: {
    type: [String],
    default: [],
  },
}, {
  timestamps: true,
});

class SeriesClass {
  static async firstOrCreate(query, doc = query) {
    const series = await this.findOne(query);
    if (series) { return { series, newRecord: false }; }
    return { series: await this.create(doc), newRecord: true };
  }

  addAsinIfNotIncludes(asin) {
    if (!this.asins.includes(asin)) { this.asins.push(asin); }
    return this;
  }

  mergeAuthors(authors) {
    for (const author of authors) {
      if (!this.authors.includes(author)) { this.authors.push(author); }
    }
    return this;
  }
}
seriesSchema.loadClass(SeriesClass);

const Series = connection.model('Series', seriesSchema);
Series.shcema = seriesSchema;

module.exports = Series;

{'fraction_non_alphanumeric': 0.15214820654316122, 'fraction_numerical': 0.0, 'mean_word_length': 3.2871621621621623, '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': '1158900', 'n_tokens_mistral': 837, 'n_tokens_neox': 826, 'n_words': 197}