Ticket: Migration Chapter 3

Hi all, im having trouble understanding the migration ticket, could someone help me please?
Below are the instructions and my code. I like to think in on the right path but I could be going down a rabbit hole.

/**

  • Ticket: Migration
  • Update all the documents in the movies collection, such that the
  • “lastupdated” field is stored as an ISODate() rather than a string.
  • The Date.parse() method build into Javascript will prove very useful here!
  • Refer to CRUD Operations
    */

// TODO: Create the proper predicate and projection
// add a predicate that checks that the lastupdated field exists, and then
// check that its type is a string
// a projection is not required, but may help reduce the amount of data sent
// over the wire!

const predicate = { updateMany: { lastUpdated:{$exists: true, $type :"string"}} }

Thanks,
-Christian

Hi @Christian_Gomez_Mart, your query predicate looks good to me.
However, you now need to update all those documents that you have received in the variable cursor.
Please read more about the $set operator and use it for changing the values of a document through the update command.

I hope it helps.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

If you look at how the variable predicate is used you will see that it is the first argument of the find method. As such, it means it is a query. The general form of a query is

{ field_name : field_value }

So in your case, field_name is updateMany and field_value is

I do not think that a field named updateMany exists in any document of this collection.

In addition, the requirement is for field lastupdated and you used lastUpdated.

Thank you @SourabhBagrecha and @steevej, I fixed the spelling in lastupdated and also removed the $type:"string" and passed all the test.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.