> ## Documentation Index
> Fetch the complete documentation index at: https://docs.base44.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Entity Schemas

> הגדר מבני נתונים מותאמים באמצעות JSON Schema עם כללי validation וסוגי שדות

<div className="dev-docs-banner">
  <div className="dev-docs-banner-content">
    <div className="dev-docs-banner-title">
      אתה צופה בתיעוד למפתחים
    </div>

    <div className="dev-docs-banner-text">
      תיעוד זה מיועד למפתחים העובדים עם פלטפורמת המפתחים של Base44. למידע על ניהול נתוני האפליקציה באמצעות עורך האפליקציות, ראה <a href="/Building-your-app/Managing-your-app-data">ניהול נתוני אפליקציה</a>.
    </div>
  </div>
</div>

Entities מוגדרים באמצעות JSON Schema המתאר את מבנה הנתונים וכללי ה-validation.

## מבנה schema בסיסי

Entity schemas מוגדרים בקבצי JSON בתיקיית ה-entities של הפרויקט שלך. כברירת מחדל, זה `base44/entities/`, אבל אתה יכול להתאים את הנתיב ב[תצורת הפרויקט שלך](/developers/backend/overview/project-structure#config-jsonc). שם הקובץ קובע את שם ה-entity. לדוגמה, `Task.json` יוצר entity בשם `Task`.

הנה תבנית של entity schema:

```json theme={null}
{
  "name": "my_entity",
  "type": "object",
  "title": "My Entity",
  "description": "Description of what this entity represents",
  "properties": {
    "<field_name>": {
      "type": "<field_type>",
      "<option>": "<value>"
    }
  },
  "required": ["<field_name>"]
}
```

## שדות מובנים

כל רשומת entity כוללת אוטומטית את השדות הבאים. אל תגדיר שדות עם שמות אלה ב-schema שלך.

| Field                     | Type     | תיאור                           |
| ------------------------- | -------- | ------------------------------- |
| `id`                      | string   | מזהה ייחודי עבור הרשומה         |
| `created_date`            | datetime | מתי הרשומה נוצרה                |
| `updated_date`            | datetime | מתי הרשומה עודכנה לאחרונה       |
| `created_by`              | string   | אימייל של המשתמש שיצר את הרשומה |
| `created_by_id`           | string   | מזהה המשתמש שיצר את הרשומה      |
| `is_deleted` (internal)   | boolean  | דגל soft delete                 |
| `deleted_date` (internal) | datetime | מתי הרשומה נמחקה                |
| `is_sample` (internal)    | boolean  | האם הרשומה היא נתוני sample     |
| `entity_name` (internal)  | string   | שם סוג ה-entity                 |
| `app_id` (internal)       | string   | App ID                          |
| `environment` (internal)  | string   | או `prod` או `dev`              |

שדות פנימיים לא מוחזרים בתגובות API אבל ניתנים להפניה ב[security rules](/developers/backend/resources/entities/security).

## שדות Schema

<ResponseField name="name" type="string">
  מזהה מחרוזת עבור ה-entity.
</ResponseField>

<ResponseField name="type" type="string" required>
  חייב להיות `"object"`.
</ResponseField>

<ResponseField name="title" type="string">
  שם תצוגה ידידותי למשתמש.
</ResponseField>

<ResponseField name="description" type="string">
  תיאור של מה ה-entity מייצג.
</ResponseField>

<ResponseField name="properties" type="object" required>
  אובייקט המכיל את הגדרות השדה שלך. לכל שדה יש `type` וכללי
  validation אופציונליים.
</ResponseField>

## סוגי שדה

Entities תומכים בסוגי שדה שונים כדי להגדיר סוגי נתונים שונים שניתן לאחסן: `string`, `integer`, `number`, `boolean`, `array`, ו-`object`.
כל שדה בתוך `properties` דורש `type`. בהתבסס על הסוג, אתה יכול להוסיף אפשרויות validation.

### שדות String

שדות string תומכים באפשרויות אלו:

* **`minLength`** / **`maxLength`**: שלוט במספר תווים מינימלי ומקסימלי.
* **`pattern`**: ביטוי רגולרי ל-validation מותאם.
* **`format`**: פורמטים מוגדרים מראש. ערכים נתמכים:
  * `"date"`
  * `"date-time"`
  * `"time"`
  * `"email"`
  * `"uri"`
  * `"hostname"`
  * `"ipv4"`
  * `"ipv6"`
  * `"uuid"`
* **`enum`**: הגבל לערכים ספציפיים מותרים. הגדר כמערך: `["value1", "value2", "value3"]`.
* **`default`**: ערך ברירת מחדל אם לא סופק.

### שדות Integer

שדות integer תומכים באפשרויות אלו:

* **`minimum`** / **`maximum`**: הגדר גבולות תחתון/עליון כולל.
* **`default`**: ערך ברירת מחדל אם לא סופק.

### שדות Number

שדות number תומכים באפשרויות אלו:

* **`minimum`** / **`maximum`**: הגדר גבולות תחתון/עליון כולל.
* **`default`**: ערך ברירת מחדל אם לא סופק.

### שדות Boolean

שדות boolean תומכים באפשרויות אלו:

* **`default`**: ערך ברירת מחדל אם לא סופק.

### שדות Array

שדות array תומכים באפשרויות אלו:

* **`items`**: הגדר את ה-type/schema עבור אלמנטים של array.
* **`default`**: ערך array ברירת מחדל אם לא סופק.

### שדות Object

שדות object תומכים באפשרויות אלו:

* **`properties`**: הגדר את השדות בתוך האובייקט.
* **`required`**: רשימה של שמות מאפיינים נדרשים.

## שדות נדרשים

ציין אילו שדות חייבים להיות מסופקים:

```json theme={null}
{
  "required": ["title", "email"]
}
```

## דוגמה מלאה

הנה entity schema שלם:

```json theme={null}
{
  "name": "Task",
  "type": "object",
  "title": "Task",
  "description": "A task item with priority, due date, and completion status",
  "properties": {
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "description": {
      "type": "string",
      "maxLength": 1000
    },
    "priority": {
      "type": "string",
      "enum": ["low", "medium", "high"],
      "default": "medium"
    },
    "completed": {
      "type": "boolean",
      "default": false
    },
    "due_date": {
      "type": "string",
      "format": "date"
    },
    "tags": {
      "type": "array",
      "items": { "type": "string" }
    },
    "internal_notes": {
      "type": "string",
      "rls": {
        "read": {"user_condition": {"role": "admin"}},
        "write": {"user_condition": {"role": "admin"}}
      }
    }
  },
  "required": ["title"],
  "rls": {
    "create": true,
    "read": {"created_by": "{{user.email}}"},
    "update": {"created_by": "{{user.email}}"},
    "delete": {"created_by": "{{user.email}}"}
  }
}
```

## פריסת entities

לאחר הגדרת ה-entity schema שלך, פרוס אותו ל-Base44 באמצעות [`entities push`](/developers/references/cli/commands/entities-push). Entities נפרסים גם אוטומטית כאשר אתה מריץ את פקודת [`deploy`](/developers/references/cli/commands/deploy) כדי לפרוס את כל הפרויקט שלך.

לאחר הפריסה, אתה יכול לתקשר עם ה-entities שלך באמצעות [מודול ה-`entities` של ה-SDK](/developers/references/sdk/docs/type-aliases/entities). שם ה-entity ב-schema שלך חייב להתאים בדיוק לאופן שבו אתה ניגש אליו ב-SDK, כולל אותיות גדולות. לדוגמה, אם ל-schema שלך יש `"name": "Task"`, אתה חייב לגשת אליו כ-`base44.entities.Task.list()`.

ניתן לצפות ב-entity schemas שנפרסו בלוח הבקרה בקטע **Data**.

## ראה גם

* [User Schema](/developers/backend/resources/entities/user-schema): entity מובנה מיוחד לאימות משתמשים
* [Security](/developers/backend/resources/entities/security): הגדר כללי row-level security עבור entities
* [Project Structure](/developers/backend/overview/project-structure): כיצד entity schemas משתלבים בפרויקט שלך

<Note>דף זה תורגם באמצעות בינה מלאכותית. למידע המדויק והעדכני ביותר, עיין ב[גרסה האנגלית](/). </Note>
