ticket:Migration

Hi All,
I am getting below error while running node movie-last-updated-migration.js command.

Error during migration, MongoError: cannot do raw queries on admin in atlas

Me too, have you made any progress with that?

Apparently specifying the database expressly solves the problem, ie use “sample_mflix” instead of “process.env.MFLIX_NS”

1 Like

Hi @Nnamdi_98218,
I did as per your comment but now when i enter
node movie-last-updated-migration.js
its stuck
my code looks like

const predicate = { 'lastupdated': { $exists: true,$type:'string' } }
const projection = {'lastupdated':1}
const cursor = await mflix
  .collection("movies")
  .find(predicate, projection)
  .toArray()
const moviesToMigrate = cursor.map(({ _id, lastupdated }) => ({
  updateOne: {
    filter: { _id: ObjectId(_id) },
    update: {
      $set: { lastupdated: new Date(Date.parse(lastupdated)) },
    },
  },
}))
1 Like

Still having this challenge? I understand the particular script can take some time to complete

1 Like

yes @Nnamdi_98218 ,
I waited for some time and it completed…

1 Like

It helped me to fix the issue with the lastupdated. Many Many thanks

1 Like