import pymongo import time from mongo import mongodb from mongo import re_pos_int db = mongodb() def delete_target(COLLECTION, *depends): db_coll = db[COLLECTION] _id = input("删哪个ID> ") target = {'_id': re_pos_int(_id)} result_find = db_coll.find_one(target) # print(db_coll.find()[0]) if result_find: result = db_coll.delete_one(target) print("删除成功") time.sleep(1) else: print("未找到此ID,重新输入> ") delete_target(COLLECTION) for depend in depends: db_coll = db[depend] depend_find = db_coll.find_one(target) # 删除排行榜等表单中此UserID的相关数据(找到了就删,找不到进娃娃机逻辑) # 不够严谨,限时活动有的表单没找到东西也会走elif
import pymongo import time from mongo import mongodb from mongo import re_pos_int dbData = mongodb() # 连接到集合(表):myDatabase.myCollection COLLECTION_DATA = "user_data" COLLECTION_LEVEL = "user_level" db_coll_data = dbData[COLLECTION_DATA] db_coll_level = dbData[COLLECTION_LEVEL] _id = input("改哪个ID:") _level = input("最大关卡数> ") # 检索目标并修改关卡数据 target = {'_id': int(_id)} udata = db_coll_data.find_one(target) # 用户最大关卡数字段 udata['r'] = int(_level) ulevel = db_coll_level.find_one(target) ulevel['a'] = {} isGold = input('1.关卡全金;2.非金卡座> ') int_isGold = re_pos_int(isGold) if int_isGold == 1: for i in range(1, int(_level) + 1): ulevel['a'][str(i)] = "400000_3_1" else: