import json from rldd import rldd2 db = rldd2.REMOTE_connect() user_list = json.load(open('result.json')) for mfc in user_list: users = user_list[mfc] users_correct = [] for user in users: users_correct.append(rldd2.getId(user)) cursor = db[mfc]['users'].update_many({"_id": { "$in": users_correct }}, {"$set": { "eQueueBoard": False }}) print(mfc, 'Progress:', cursor.modified_count, '/', cursor.matched_count)
from rldd import rldd2 result_file = open("users.csv", "w+") remote = rldd2.REMOTE_connect() dbs = remote.list_database_names() for dbName in dbs: if dbName.startswith("mfc"): db = remote[dbName] users = db["users"].find({"user_custom_role.staticUR": "OPERATOR"}) for user in users: userId = user["_id"] upd = db["users"].update_one({"_id": userId}, {"$set": { "eQueueBoard": True }}) if upd.modified_count == 1: result_file.write(f"{dbName};{userId}\n") result_file.close() users.close()
from bson import DBRef, ObjectId from rldd import rldd2 from user import rldd_user import datetime remoteConn = rldd2.REMOTE_connect() remoteBases = remoteConn.list_database_names() for base in remoteBases: if base.startswith('mfc'): remote = remoteConn[base] # USERS users = remote["users"].find({"user_custom_role.staticUR": "OPERATOR"}) for user in users: userId = user["_id"] user_custom_role = user['user_custom_role'] for index, role in enumerate(user_custom_role): if type(role) is not dict: user_custom_role[index] = role[0] upd2 = remote["users"].update_one( {"_id": userId}, {"$set": { "user_custom_role": user_custom_role }}) print( f'User {userId} has been updated on base {base}. Progress: {upd2.modified_count} / {upd2.matched_count}' )