<commit_before># mongoose-merge-plugin

Mongoose plugin for document merging

## Install npm install mongoose-merge-plugin

## Loading

  var merge = require('mongoose-merge-plugin');

## Inintialization

  var mongoose = require('mongoose');
  mongoose.plugin(merge);

## Usage

The method <i>merge</i> is added to all mongoose documents. It takes a source object as paramter and merge it in the target existing documents. It checks for existing values in the source object regarding the field path of the destination document.
It does not merge the <i>\_id</i> and <i>\_\_v</i> default fields and check for the schema field option <i>mergeable</i>, if the option is false, the merge skip the field as well.

## Example

<pre>
var mongoose = require('mongoose'),
    Schema = mongoose.Schema;
var schema = new Schema({
  name: String,
  notMergedField: { type: String, mergeable: false }
});
var model = mongoose.model('Test', schema);
var test = new Test({name: test, notMergedField: testNMF });
console.log(test); // LOG: { i_id: ..., name: test, notMergedField: testNMF ...}
test.merge({ name: testChanged, notMergedField: testNMFChanged });
console.log(test); // LOG: { i_id: ..., name: testChanged, notMergedField: testNMF ...}
</pre>

## Support

<a href="http://www.it-tweaks.com/" target="_blank">it-tweaks</a><commit_msg>Fix: model name in example<commit_after># mongoose-merge-plugin

Mongoose plugin for document merging

## Install npm install mongoose-merge-plugin

## Loading

  var merge = require('mongoose-merge-plugin');

## Inintialization

  var mongoose = require('mongoose');
  mongoose.plugin(merge);

## Usage

The method <i>merge</i> is added to all mongoose documents. It takes a source object as paramter and merge it in the target existing documents. It checks for existing values in the source object regarding the field path of the destination document.
It does not merge the <i>\_id</i> and <i>\_\_v</i> default fields and check for the schema field option <i>mergeable</i>, if the option is false, the merge skip the field as well.

## Example

<pre>
var mongoose = require('mongoose'),
    Schema = mongoose.Schema;
var schema = new Schema({
  name: String,
  notMergedField: { type: String, mergeable: false }
});
var Test = mongoose.model('Test', schema);
var test = new Test({name: test, notMergedField: testNMF });
console.log(test); // LOG: { i_id: ..., name: test, notMergedField: testNMF ...}
test.merge({ name: testChanged, notMergedField: testNMFChanged });
console.log(test); // LOG: { i_id: ..., name: testChanged, notMergedField: testNMF ...}
</pre>

## Support

<a href="http://www.it-tweaks.com/" target="_blank">it-tweaks</a>
{'fraction_non_alphanumeric': 0.1350037397157816, 'fraction_numerical': 0.0, 'mean_word_length': 4.425963488843814, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7330765', 'n_tokens_mistral': 833, 'n_tokens_neox': 848, 'n_words': 293}