javascript - How would you convert Binary field of type 4 to type 0? -
how convert binary field of type 4 type 0 using shell script ?
i thought running simple script this
db.places.find({}).foreach(function(data) { // how data ? print(data.id); // db.places.update(....) });
but couldn't figure out how binary data can construct new binary. object.keys()
shows there 2 fields: type
, len
you can not force type. don't quite understand why want this, can rewrite document force new type:
db.places.insert( { id: new bindata( 0x04, "sevmte8=" ) } ); db.places.find(); { "_id" : objectid("5204c4f252d346a74dd17755"), "id" : bindata(4,"sevmte8=") }
so script, can this:
db.places.find({}).foreach(function(data) { bindata = data.id.base64(); db.places.update( { _id: data._id }, { $set: { id : new bindata(0, bindata) } } ); });
Comments
Post a Comment