<commit_before>import mongoose, { Schema } from 'mongoose';

/**
 * CategorySchema
 * - Category represents a unique category that holds a collection of imageUrls.
 * - i.e. { photos: ['https://myPhoto.jpg', 'https://myPhoto2.jpg']}
 */
const CategorySchema = new Schema({
  // Declare a unique name for each category.
  name: {
    required: true,
    type: String,
    unique: true
  },
  // This is the array of images.
  photos: [{
    type: String,
    unique: true
  }]
});

/**
 * addPhoto(arg1, arg2)
 * - @param {String} name
 * - @param {Object} image
 * - @return {Promise} saved Photo, updated array on Category.
 * - NOTE: Schema.statics allows for creating methods
 * - on the Schema class.
 */
CategorySchema.statics.addPhoto = async function (name, image) {
  // Find category 'name' & push the imageUrl to the key 'photos' array.
  const list = await this.findOneAndUpdate(name, { $push: { photos: image.url } });
  // Return the updated category.
  return list;
};
<commit_msg>clean code<commit_after>import mongoose, { Schema } from 'mongoose';

/**
 * CategorySchema
 */
const CategorySchema = new Schema({
  // Declare a unique name for each category.
  name: {
    required: true,
    type: String,
    unique: true
  },
  // This is the array of images.
  photos: []
});

/**
 * addPhoto(arg, arg2)
 * - @param {String} name
 * - @param {Object} image
 * - @return {Promise} saved Photo, updated array on Category.
 * - NOTE: Schema.statics allows for creating methods
 * - on the Schema class.
 */
CategorySchema.statics.addPhoto = async function (name, image) {
  // Find category 'name' & push the imageUrl to the key 'photos' array.
  const list = await this.findOneAndUpdate(name, { $push: { photos: image.url } });
  // Return the updated category.
  return list;
};

{'fraction_non_alphanumeric': 0.1358574610244989, 'fraction_numerical': 0.0022271714922048997, 'mean_word_length': 3.1597222222222223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2862443', 'n_tokens_mistral': 551, 'n_tokens_neox': 551, 'n_words': 192}