# المستكمل

Canonical URL: https://developers.iagenify.com/ar/sdk/ref/connected-storage/run-write/update/
Language: ar

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

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

Status: document database · free · one by default

## المعاملات {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `collection` | string | مطلوب | -أيّ جمع جمع |
| `filter` | JSON text | مطلوب* | أي وثائق. `all: true`. |
| `update` | JSON text | مطلوب | عمال التشغيل `$set`, `$inc`, `$unset`, `$push`وثيقة بسيطة مرفوضة |
| `many` | boolean |  | `true` تحديثات كل متطابق. الإفتراضي: واحد. |
| `all` | boolean |  | إلى معاينة a فارغ. |

```javascript
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 }
```

## رفض تقديم وثيقة كاملة {#operators}

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

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

// Meant
update: JSON.stringify({ $set: { active: false } })
```

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

| تكتب | "تلمس" |
| --- | --- |
| لا شيء آخر | الـ الأول |
| مُنت كثيرة: | كل ما يتطابق |
| لا | لا شيء |
| لا فارغ، كل: 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.

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

if (res.matchedCount !== expected) {
  console.warn(`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.

- [تحذف عبارة](/ar/sdk/ref/connected-storage/run-write/delete): "ليه ماي" "ليه" "ليه"
- [run()](/ar/sdk/ref/connected-storage/run): إلى حد ما أفعال، مثل garede-fuus و se que chacune coamte.

```python
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}
```

```python
# Refused
update = json.dumps({"active": False})

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

```python
res = storage.run(action="update", collection=collection, filter=filter, update=update, many=True)

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