db.test.aggregate([
{
"$addFields":{
"sharesFloat": {
"$function": {
"body": "function (shares) { if (!shares) {return 0}; return parseFloat(shares.split(' ')[0])}",
"args": ["$obj.shares"],
"lang": "js"
}
}
}
},
{
"$group": {
"_id": None,
"sum": {
"$sum": "$sharesFloat"
}
}
}
])
db.collection.update_many(
{"delivery_rub": {"$lt": 0}},
[
{
"$set": {
"delivery_rub": {
"$multiply": [
"$delivery_rub",
-1
]
}
}
}
])
cluster = AsyncIOMotorClient("")
db = cluster['Users']
collection = db['Words']
data = await collection.find().to_list(None)
for i in collection.find(query):
for i in collection.find(*query):
if products == None:
msg = "Пусто"
if not products:
msg = "Пусто"
if db.test.count_documents({"_id": name}) > 0:
print("Уже существует")
collection_name.update_one({"_id": ...}, {"$pull": {"list": "Позиция 0"}})
collection_name.update_one({_id: ..., "list": "Позиция 0"}, {"$set: {"list.$": "Позиция 00"}})