Aug-20-2019, 11:59 AM
Hi ,
I'm using below script in Robot mongo to update key value to and ObjectId type.
This is working perfectly
db.getCollection('tags').find({oid:{$not: {$type: 7}}}).forEach(function(x){
x.oid = ObjectId(x.oid);
db.getCollection('tags').save(x);
});
But I need to code same thing in python.
below python script get the collection I need to convert the objectId type but I'm not sure how to update it
db = client[db_name]
my_coll = db['tags']
Query={"oid":{"$not": {"$type": 7}}}
list1=my_coll.find(Query)
for x in list1:
pprint(x )
any support appreciated
I'm using below script in Robot mongo to update key value to and ObjectId type.
This is working perfectly
db.getCollection('tags').find({oid:{$not: {$type: 7}}}).forEach(function(x){
x.oid = ObjectId(x.oid);
db.getCollection('tags').save(x);
});
But I need to code same thing in python.
below python script get the collection I need to convert the objectId type but I'm not sure how to update it
db = client[db_name]
my_coll = db['tags']
Query={"oid":{"$not": {"$type": 7}}}
list1=my_coll.find(Query)
for x in list1:
pprint(x )
any support appreciated