& جاري

المستكمل

storage.run({ action: "update", collection, filter, update, many, all })

تغييرات في الوثائق التي تطابقها، المشغلات فقط، والمرشح الفارغ يجب أن يكون المقصود.

document databasefreeone by default
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

المعاملات

collectionstringمطلوب

-أيّ جمع جمع

filterJSON textمطلوب*

أي وثائق. all: true.

updateJSON textمطلوب

عمال التشغيل $set, $inc, $unset, $pushوثيقة بسيطة مرفوضة

manyboolean

true تحديثات كل متطابق. الإفتراضي: واحد.

allboolean

إلى معاينة a فارغ.

await storage.run({
  action: "update",
  collection: "users",
  filter: JSON.stringify({ email: "a@example.com" }),
  update: JSON.stringify({ $set: { active: false }, $inc: { logins: 1 } }),
});
// { matchedCount: 1, modifiedCount: 1 }
import json

storage.run(
    action="update",
    collection="users",
    filter=json.dumps({"email": "a@example.com"}),
    update=json.dumps({"$set": {"active": False}, "$inc": {"logins": 1}}),
)
# {"matchedCount": 1, "modifiedCount": 1}

رفض تقديم وثيقة كاملة

ومن شأن تمرير وثيقة أن يحل محلها، والحقول، وجميع

}الأنشطة: كاذبة} لا تعني "الأنشطة النشطة للتزوير" - وهذا يعني أن "هذه هي الآن الوثيقة بأكملها، وكل حقل آخر قد اختفى، والرفض موجود لأن هذا الخطأ صامت ولا رجعة فيه.

// Refused
update: JSON.stringify({ active: false })

// Meant
update: JSON.stringify({ $set: { active: false } })
# Refused
update = json.dumps({"active": False})

# Meant
update = json.dumps({"$set": {"active": False}})

واحد بالتخلف، وكثير من الطلب

تكتب"تلمس"
لا شيء آخرالـ الأول
مُنت كثيرة:كل ما يتطابق
لالا شيء
لا فارغ، كل: fi حقيقيكل وثيقة من وثائق جمع

The default of one is the conservative reading of an ambiguous request. Say many: true when you mean it — and read matchedCount against what you expected.

const res = await storage.run({ action: "update", collection, filter, update, many: true });

if (res.matchedCount !== expected) {
  console.warn(`expected ${expected}, matched ${res.matchedCount}`);
}
res = storage.run(action="update", collection=collection, filter=filter, update=update, many=True)

if res["matchedCount"] != expected:
    print(f"expected {expected}, matched {res['matchedCount']}")

matchedCount and modifiedCount differ when a document already had the value — matched but not changed. That is not a failure.