MongoDB: Updating documents using current fields value
<p>I have mongodb "Mydb" with collection "users".</p>

<pre><code>export let User = mongoose.model("User", UserSchema);

let UserSchema = new mongoose.Schema({
      phone           : {
        type    : String,
        validate: {
</code></pre>

<p>Now I want to update field "phone" replacing whitespaces (for example). I try to use following:</p>

<pre><code>User.update({}, {$set : {'phone': //here is my problem}},
{multi: true, upsert:false}, () =&gt; next());
</code></pre>

<p>How can I get current "phone" value to replace it? (I use mongoose-migrate)</p>

<p>As I said I try to use mongoose-migration module, so I've created new migration file like this:                                                                          </p>

<pre><code>    'use strict'
const mongoose = require('mongoose');
import { User, dbConnection } from '../db/index'

export function up(next) {
User.update({}, {$set : {'phone': this.phone}}, {multi: true, upsert:false}, () =&gt; next());
}


export function down(next) {
    next();
}
</code></pre>

<p>where User:</p>

<pre><code>export let User = mongoose.model("User", UserSchema);
</code></pre>