> ## 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.

# User Schema

> הרחב את entity המשתמש המובנה עם שדות נוספים עבור האפליקציה שלך.

אתה צופה בתיעוד למפתחים

תיעוד זה מיועד למפתחים העובדים עם פלטפורמת המפתחים של Base44. למידע על ניהול נתוני האפליקציה באמצעות עורך האפליקציות, ראה [ניהול נתוני אפליקציה](https://docs.base44.com/Building-your-app/Managing-your-app-data.md).

ה-entity של User קיים בכל פרויקט Base44 כברירת מחדל ושומר מידע על משתמשי האפליקציה שלך. תוכל להוסיף שדות כדי לאחסן נתוני משתמש נוספים, ואז להשתמש בשדות אלה ב[security rules](https://docs.base44.com/developers/backend/resources/entities/security.md) כדי לשלוט בגישת נתונים או באפליקציה שלך כדי להתאים אישית את החוויה.

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

כל User entity כולל סט של שדות מובנים כברירת מחדל.

| Field | Type | תיאור |
| - | - | - |
| `full_name` | string | שם תצוגה של המשתמש |
| `email` | string | כתובת אימייל של המשתמש |
| `role` | string | או `admin` או `user` |

ל-User entity יש גם את [השדות המובנים הכלליים](https://docs.base44.com/developers/backend/resources/entities/entity-schemas.md#built-in-fields) הקיימים בכל ה-entities, כגון `id`, ו-`created_date`.

שדות אלה מנוהלים על ידי המערכת ולא ניתן להגדירם מחדש ב-schema שלך.

## שדות מותאמים

כדי להוסיף שדות מותאמים, הגדר User schema המכיל רק את השדות הנוספים שלך. ניסיון להגדיר מחדש שדות מובנים יגרום לשגיאת validation.

צור קובץ `User.json` או `User.jsonc` בתיקיית ה-entities של הפרויקט שלך. כברירת מחדל זה `base44/entities/`, אבל אתה יכול להתאים את הנתיב ב[תצורת הפרויקט שלך](https://docs.base44.com/he/developers/backend/overview/project-structure.md#config-jsonc).

```json entities/User.json theme={null}
{
  "name": "User",
  "type": "object",
  "properties": {
    "company": { "type": "string" },
    "phone": { "type": "string" },
    "job_title": { "type": "string" },
    "bio": { 
      "type": "string",
      "maxLength": 500
    }
  },
  "required": ["company"]
}
```

ואז דחוף את ה-entities שלך ל-Base44 באמצעות [`entities push`](https://docs.base44.com/developers/references/cli/commands/entities-push) או [`deploy`](https://docs.base44.com/developers/references/cli/commands/deploy).

## דוגמה מלאה

הנה User schema שלם עם סוגי שדה שונים:

```json theme={null}
{
  "name": "User",
  "type": "object",
  "properties": {
    "company": {
      "type": "string"
    },
    "phone": {
      "type": "string"
    },
    "job_title": {
      "type": "string",
      "maxLength": 100
    },
    "bio": {
      "type": "string",
      "maxLength": 500
    },
    "website": {
      "type": "string",
      "format": "uri"
    },
    "preferences": {
      "type": "object",
      "properties": {
        "theme": {
          "type": "string",
          "enum": ["light", "dark"],
          "default": "light"
        },
        "notifications": {
          "type": "boolean",
          "default": true
        }
      }
    }
  },
  "required": ["company"]
}
```

## השתמש בשדות שלך

לאחר שהגדרת ודחפת את ה-User schema שלך, אתה יכול להפנות לשדות שלך ב-security rules ולגשת אליהם בקוד האפליקציה שלך.

### ב-security rules

אתה יכול להשתמש בשדות משתמש כדי לשלוט בגישה ל-entities אחרים. לדוגמה, אתה עשוי להגביל משתמשים לראות רק רשומות השייכות לחברה שלהם.

כדי להפנות לשדות משתמש ב-[security rules](https://docs.base44.com/developers/backend/resources/entities/security.md), השתמש בתחביר התבנית `{{user.data.*}}`:

```json theme={null}
{
  "rls": {
    "read": {"data.company": "{{user.data.company}}"},
    "update": {"data.company": "{{user.data.company}}"}
  }
}
```

כלל זה מבטיח שמשתמשים יכולים לקרוא ולעדכן רק רשומות שבהן שדה ה-`company` של הרשומה מתאים לשלהם.

### בקוד

גש לשדות משתמש דרך ה-[SDK](https://docs.base44.com/developers/references/sdk/getting-started/overview.md):

```typescript theme={null}
// Get current user's fields
const currentUser = await base44.auth.me();
console.log(currentUser.company); // "Acme Inc"

// Update current user's fields
await base44.auth.updateMe({
  phone: "+1-555-0123",
  job_title: "Senior Developer"
});

// List all users with service role (backend functions only)
const allUsers = await base44.asServiceRole.entities.User.list();
```

> [!NOTE]
>
> דוגמה זו משתמשת בלקוח `base44`. ראה [Setting up the client](https://docs.base44.com/developers/references/sdk/getting-started/client.md) להוראות הגדרה.

## ראה גם

* [Entities Overview](https://docs.base44.com/developers/backend/resources/entities/overview.md): למד על תצורת schema של מסד הנתונים
* [Entity Schemas](https://docs.base44.com/developers/backend/resources/entities/entity-schemas.md): הגדר את מבנה ה-entity שלך
* [Security](https://docs.base44.com/developers/backend/resources/entities/security.md): הגדר כללי row-level security
* [Project Structure](https://docs.base44.com/developers/backend/overview/project-structure.md): כיצד entity schemas משתלבים בפרויקט שלך

> [!NOTE]
>
> דף זה תורגם באמצעות AI. למידע המדויק והעדכני ביותר, עיין ב[גרסה האנגלית](https://docs.base44.com/index.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.