Responsive Ad Area

Share This Post

test

Mongo datatype change to Boolean

I have a mongo document as below.

{   "products" : [
     {
       "name" : "test",
       "available" " "true"
     },
     {
       "name" : "test",
       "available" " "true"
     },
     {
       "name" : "test",
       "available" " "true"
     }    ] }

Here, I want to change the status to true( type –>> boolean from string) for all the documents. I have 6 million records in the collection. There are some documents with no products field and it is an array field.
What is the best and fastest query.

The below query works for non array. Not sure, how to make it working for an array field.

db.coll.update({}, {
   $set: {products.available: false}
}, { multi: true })

Thanks


Mongo datatype change to Boolean
Mongo datatype change to Boolean
test
{$excerpt:n}

Share This Post

Leave a Reply

Your email address will not be Publishedd. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Skip to toolbar