<commit_before>/**
 * Common methods for the Posts model.
 */
_.extend(Posts, {
  /**
   * Add the collection
   * @type {Meteor}
   */
  collection:  new Meteor.Collection('posts'),

  /**
   * Return the top latest posts
   * @return {Mongo.Cursor}
   */
  all: function(callback) {
    return Posts.collection.find({}, {}, callback);
  },

  /**
   * Inserts a new post into the post collection
   * @param  {Object}   post     Inital data to set in the collection
   * @param  {Function} callback Optional callback
   * @return {String}            MongoID for the new entity
   */
  create: function(post, callback) {
    return Posts.collection.insert(post, callback);
  },

  /**
   * Return a single post
   * @param  {String} id Post id
   * @return {Document}
   */
  get: function(id, callback) {
    return Posts.collection.findOne({_id: id}, {}, callback);
  },

  /**
   * Update an entities properties
   * @param  {String}   id        Post id for the target entity
   * @param  {Object}   changes   Key/Value pair of changes to be applied
   * @param  {Function} callback  Callback
   * @return {Number}
   */
  update: function(id, changes, callback) {<commit_msg>Clean schema on client to populated autoValues<commit_after>/**
 * Common methods for the Posts model.
 */
_.extend(Posts, {
  /**
   * Add the collection
   * @type {Meteor}
   */
  collection:  new Meteor.Collection('posts'),

  /**
   * Return the top latest posts
   * @return {Mongo.Cursor}
   */
  all: function(callback) {
    return Posts.collection.find({}, {}, callback);
  },

  /**
   * Inserts a new post into the post collection
   * @param  {Object}   post     Inital data to set in the collection
   * @param  {Function} callback Optional callback
   * @return {String}            MongoID for the new entity
   */
  create: function(post, callback) {
    /**
     * @see https://github.com/aldeed/meteor-collection2/issues/62
     *      Seems that in order to use the schema to generate autoValues and defaultValue's
     *      we have to call clean on the client.
     */
    if(Meteor.isClient)
      post = Posts.schema.clean(post);

    // Run the insert
    return Posts.collection.insert(Posts.schema.clean(post), callback);
  },

  /**
   * Return a single post
   * @param  {String} id Post id
   * @return {Document}
   */
  get: function(id, callback) {
    return Posts.collection.findOne({_id: id}, {}, callback);
  },

  /**
   * Update an entities properties
   * @param  {String}   id        Post id for the target entity
   * @param  {Object}   changes   Key/Value pair of changes to be applied
   * @param  {Function} callback  Callback
   * @return {Number}
   */
  update: function(id, changes, callback) {
{'fraction_non_alphanumeric': 0.12449504223283143, 'fraction_numerical': 0.0011017260374586854, 'mean_word_length': 2.632, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '642795', 'n_tokens_mistral': 846, 'n_tokens_neox': 812, 'n_words': 265}