title: Convert String fields to ObjectID fields in MongoDB using Mongoose
body: <p>I have a MongoDB database with two schemas - users and posts. It used to look like this:</p>
  
  <pre><code>username: {type: String},
  following: {type: [String], ref: 'users'}
  
  user_id: {type: String, ref: 'users'}
  comment: {type: String}
  </code></pre>
  
  <p>But now I've decided to change reference fields' types from String to ObjectId so now I have:</p>
  
  <pre><code>username: {type: String},
  following: {type: [Schema.Types.ObjectId], ref: 'users'}
  
  user_id: {type: Schema.Types.ObjectId, ref: 'users'}
  comment: {type: String}
  </code></pre>
  
  <p>But the old data in the database is still stored as Strings. How can I migrate that data properly?</p>
  
  <p>I use Mongoose to query the database from my code.</p>