-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongoapp.py
More file actions
67 lines (66 loc) · 2.04 KB
/
mongoapp.py
File metadata and controls
67 lines (66 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from pymongo import MongoClient
# pprint library is used to make the output look more pretty
from pprint import pprint
# connect to MongoDB, change the << MONGODB URL >> to reflect your own connection string
client = MongoClient("mongodb://uber:admin@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin")
db=client.admin
# Issue the serverStatus command and print the results
#serverStatusResult=db.command("serverStatus")
#pprint(serverStatusResult)
result = db.Users.find()
total_accounts=len(list(result)) #get number of total accounts
print("Total accounts:", total_accounts)
for i in range(1,total_accounts+1): #iterate through all documents in Users collection, add +1 to total_accounts so last document will be updated as well
db.Users.update_one(
{ "UserId" : i },
{ "$set": { "Inventory": [
{
"AmountRemaining": -1,
"Cmid": i,
"ExpirationDate": None,
"ItemId": 1
},
{
"AmountRemaining": -1,
"Cmid": i,
"ExpirationDate": None,
"ItemId": 12
}
]} }
)
db.Users.update_one(
{ "UserId" : i },
{ "$set": { "Loadout": {
"Backpack": 0,
"Boots": 1089,
"Cmid": i,
"Face": 0,
"FunctionalItem1": 0,
"FunctionalItem2": 0,
"FunctionalItem3": 0,
"Gloves": 1086,
"Head": 1084,
"LoadoutId": 0,
"LowerBody": 1088,
"MeleeWeapon": 1,
"QuickItem1": 0,
"QuickItem2": 0,
"QuickItem3": 0,
"SkinColor": "#FFFFFF",
"Type": 0,
"UpperBody": 1087,
"Weapon1": 12,
"Weapon1Mod1": 0,
"Weapon1Mod2": 0,
"Weapon1Mod3": 0,
"Weapon2": 0,
"Weapon2Mod1": 0,
"Weapon2Mod2": 0,
"Weapon2Mod3": 0,
"Weapon3": 0,
"Weapon3Mod1": 0,
"Weapon3Mod2": 0,
"Weapon3Mod3": 0,
"Webbing": 0
}} }
)