# تحذف عبارة

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

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

يزيل مستندات تطابق -- أو كائن من a كلّ مباراة افتراضيّة، الذي هو واحد قيمة معرفة هنا.

Status: document database · object storage · free · all matches by default

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

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `collection` | string | مطلوب* | - - قاعدة بيانات الوثائق. |
| `filter` | JSON text | مطلوب* | أي وثائق. `all: true`. |
| `many` | boolean |  | `false` يزيل a واحد مستند. إفتراضي: كل متطابق. |
| `all` | boolean |  | إلى معاينة a فارغ. |
| `key` | string | مطلوب* | - لا يجوز أن يكون هناك أي غرض آخر. |

```javascript
// Documents
await storage.run({ action: "delete", collection: "sessions",
  filter: JSON.stringify({ expiresAt: { $lt: new Date().toISOString() } }) });
// { ok: true, deletedCount: 142 }

// An object
await storage.run({ action: "delete", key: "invoices/2026/01/a.pdf" });
```

> **هذا واحد إلى كل متطابق، على عكس تحديث**
>
> تحديث يمس واحد ما لم تقل الكثير: صحيح؛ حذف يزيل كل منهم إلا إذا قلت الكثير: خاطئ. الاثنتان مختلفتان، والفرق لا يمكن استرداده في اتجاه واحد.

## يجري رفض % مُرر {#empty}

```javascript
// Refused: this would empty the collection
await storage.run({ action: "delete", collection: "logs", filter: JSON.stringify({}) });

// Accepted: you said so, explicitly
await storage.run({ action: "delete", collection: "logs",
  filter: JSON.stringify({}), all: true });
```

ويمر الحارس قبل وصول أي شيء إلى قاعدة البيانات، وقبل أن يطلب الإذن من وكيل - بحيث يتوقف الشكل الخطير دون حاجة إلى حكم من أي شخص.

## & عليك حذف {#count-first}

نفس المرشح، معدود أولاً، يخبرك ما هو على وشك الذهاب. إنه حر، وهو المعاينة الوحيدة التي تحصل عليها.

```javascript
const { count } = await storage.run({ action: "count", collection, filter });
if (count > 1000) throw new Error(`that filter matches ${count} documents — check it`);

await storage.run({ action: "delete", collection, filter });
```

## جاري الإزالة يعمل حتى عندما يكون التخزين ممتلئاً {#quota}

فالكتابات تُرفض بعد الحصة ، والحذف لا ، وهكذا تصنع الغرفة ، مخزن لا يمكنك ان تفرغه لأنه كامل ، سيكون فخا .

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

```python
import json
from datetime import datetime, timezone

# Documents
storage.run(action="delete", collection="sessions",
            filter=json.dumps({"expiresAt": {"$lt": datetime.now(timezone.utc).isoformat()}}))
# {"ok": True, "deletedCount": 142}

# An object
storage.run(action="delete", key="invoices/2026/01/a.pdf")
```

```python
import json

# Refused: this would empty the collection
storage.run(action="delete", collection="logs", filter=json.dumps({}))

# Accepted: you said so, explicitly
storage.run(action="delete", collection="logs", filter=json.dumps({}), all=True)
```

```python
count = storage.run(action="count", collection=collection, filter=filter)["count"]
if count > 1000:
    raise ValueError(f"that filter matches {count} documents — check it")

storage.run(action="delete", collection=collection, filter=filter)
```
