Merge remote changes and update project files
This commit is contained in:
268
setup/PRODUCTS_COLLECTION_SCHEMA.md
Normal file
268
setup/PRODUCTS_COLLECTION_SCHEMA.md
Normal file
@@ -0,0 +1,268 @@
|
||||
# Products Collection Schema
|
||||
|
||||
Diese Datei beschreibt alle Attribute, die in der `products` Collection benötigt werden, damit das Programm funktioniert.
|
||||
|
||||
## Collection: `products`
|
||||
|
||||
**Collection ID:** `products` (oder über `VITE_APPWRITE_PRODUCTS_COLLECTION_ID` konfiguriert)
|
||||
|
||||
## Erforderliche Attribute
|
||||
|
||||
### 1. `product_account_id` (String, Required)
|
||||
- **Typ:** String
|
||||
- **Required:** Ja
|
||||
- **Verwendung:**
|
||||
- Filterung nach Account (Query.equal)
|
||||
- Verknüpfung zu Accounts-Collection
|
||||
- **Beispiel:** `"account_123"`
|
||||
|
||||
### 2. `product_platform` (Enum, Required)
|
||||
- **Typ:** Enum
|
||||
- **Required:** Ja
|
||||
- **Werte:** `["amazon", "ebay"]`
|
||||
- **Verwendung:**
|
||||
- Speichert die Plattform (aktuell nur "ebay" wird verwendet)
|
||||
- **Beispiel:** `"ebay"`
|
||||
|
||||
### 3. `product_platform_market` (String, Required)
|
||||
- **Typ:** String
|
||||
- **Required:** Ja
|
||||
- **Verwendung:**
|
||||
- Speichert den Marktplatz (z.B. "DE", "US", "UK")
|
||||
- Wird aus Account abgeleitet
|
||||
- **Beispiel:** `"DE"`, `"US"`, `"UK"`
|
||||
|
||||
### 4. `product_platform_product_id` (String, Required, Unique)
|
||||
- **Typ:** String
|
||||
- **Required:** Ja
|
||||
- **Unique:** Ja (für Duplikat-Prüfung)
|
||||
- **Verwendung:**
|
||||
- Eindeutige Produkt-ID von der Plattform (z.B. eBay Item-ID)
|
||||
- Wird für Duplikat-Prüfung verwendet
|
||||
- Wird für Mapping zwischen Extension und Datenbank verwendet
|
||||
- **Beispiel:** `"123456789"` (eBay Item-ID)
|
||||
|
||||
### 5. `product_title` (String, Optional)
|
||||
- **Typ:** String
|
||||
- **Required:** Nein
|
||||
- **Verwendung:**
|
||||
- Produkttitel
|
||||
- Wird für Anzeige in UI verwendet
|
||||
- Wird für Suchfilter verwendet (client-side)
|
||||
- **Beispiel:** `"iPhone 13 Pro Max 256GB"`
|
||||
|
||||
### 6. `product_price` (Float, Optional)
|
||||
- **Typ:** Float
|
||||
- **Required:** Nein
|
||||
- **Verwendung:**
|
||||
- Produktpreis
|
||||
- Wird für KPI-Berechnungen verwendet (Durchschnittspreis)
|
||||
- Wird für Price Spread Insights verwendet
|
||||
- **Beispiel:** `99.99`
|
||||
|
||||
### 7. `product_currency` (String, Optional)
|
||||
- **Typ:** String
|
||||
- **Required:** Nein
|
||||
- **Verwendung:**
|
||||
- Währung (z.B. "EUR", "USD", "GBP")
|
||||
- Wird aus Market abgeleitet, falls nicht vorhanden
|
||||
- **Beispiel:** `"EUR"`, `"USD"`, `"GBP"`
|
||||
|
||||
### 8. `product_url` (String, Optional)
|
||||
- **Typ:** String
|
||||
- **Required:** Nein
|
||||
- **Verwendung:**
|
||||
- URL zum Produkt auf der Plattform
|
||||
- **Beispiel:** `"https://www.ebay.de/itm/123456789"`
|
||||
|
||||
### 9. `product_status` (Enum, Optional)
|
||||
- **Typ:** Enum
|
||||
- **Required:** Nein
|
||||
- **Werte:** `["active", "ended", "unknown"]`
|
||||
- **Verwendung:**
|
||||
- Status des Produkts
|
||||
- Wird für Filterung verwendet (Overview KPIs, Products Page)
|
||||
- Wird für Status-Filter in UI verwendet
|
||||
- **Default:** `"unknown"`
|
||||
- **Beispiel:** `"active"`, `"ended"`, `"unknown"`
|
||||
|
||||
### 10. `product_category` (String, Optional)
|
||||
- **Typ:** String
|
||||
- **Required:** Nein
|
||||
- **Verwendung:**
|
||||
- Produktkategorie
|
||||
- Wird für Category Share Insights verwendet
|
||||
- **Default:** `"unknown"`
|
||||
- **Beispiel:** `"Electronics"`, `"Clothing"`
|
||||
|
||||
### 11. `product_condition` (String, Optional)
|
||||
- **Typ:** String
|
||||
- **Required:** Nein
|
||||
- **Verwendung:**
|
||||
- Zustand des Produkts (z.B. "New", "Used")
|
||||
- **Default:** `"unknown"`
|
||||
- **Beispiel:** `"New"`, `"Used"`, `"Refurbished"`
|
||||
|
||||
## Standard-Appwrite-Felder
|
||||
|
||||
Diese Felder werden automatisch von Appwrite bereitgestellt:
|
||||
|
||||
- **`$id`** (String, Required) - Eindeutige Dokument-ID
|
||||
- **`$createdAt`** (DateTime, Required) - Erstellungsdatum (wird für Sortierung verwendet)
|
||||
- **`$updatedAt`** (DateTime, Required) - Aktualisierungsdatum
|
||||
|
||||
## Indexes (Empfohlen)
|
||||
|
||||
Für bessere Performance sollten folgende Indexes erstellt werden:
|
||||
|
||||
1. **Index auf `product_account_id`** (für Filterung)
|
||||
- Attribute: `product_account_id`
|
||||
- Typ: Key
|
||||
|
||||
2. **Index auf `product_platform_product_id`** (für Duplikat-Prüfung)
|
||||
- Attribute: `product_platform_product_id`
|
||||
- Typ: Unique Key
|
||||
|
||||
3. **Index auf `product_account_id` + `$createdAt`** (für Sortierung)
|
||||
- Attribute: `product_account_id`, `$createdAt`
|
||||
- Typ: Composite
|
||||
|
||||
## Berechtigungen
|
||||
|
||||
Die Collection benötigt folgende Berechtigungen:
|
||||
|
||||
- **Read:** Authenticated Users
|
||||
- **Create:** Authenticated Users
|
||||
- **Update:** Authenticated Users
|
||||
- **Delete:** Authenticated Users (optional, falls Löschen benötigt wird)
|
||||
|
||||
## Appwrite CLI Befehle zum Erstellen
|
||||
|
||||
```bash
|
||||
# Collection erstellen
|
||||
appwrite databases createCollection \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--name "Products"
|
||||
|
||||
# Attribute erstellen
|
||||
appwrite databases createStringAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_account_id \
|
||||
--required true \
|
||||
--size 255
|
||||
|
||||
appwrite databases createEnumAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_platform \
|
||||
--elements amazon ebay \
|
||||
--required true
|
||||
|
||||
appwrite databases createStringAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_platform_market \
|
||||
--required true \
|
||||
--size 10
|
||||
|
||||
appwrite databases createStringAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_platform_product_id \
|
||||
--required true \
|
||||
--size 255
|
||||
|
||||
appwrite databases createStringAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_title \
|
||||
--required false \
|
||||
--size 500
|
||||
|
||||
appwrite databases createFloatAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_price \
|
||||
--required false
|
||||
|
||||
appwrite databases createStringAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_currency \
|
||||
--required false \
|
||||
--size 10
|
||||
|
||||
appwrite databases createStringAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_url \
|
||||
--required false \
|
||||
--size 1000
|
||||
|
||||
appwrite databases createEnumAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_status \
|
||||
--elements active ended unknown \
|
||||
--required false
|
||||
|
||||
appwrite databases createStringAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_category \
|
||||
--required false \
|
||||
--size 255
|
||||
|
||||
appwrite databases createStringAttribute \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key product_condition \
|
||||
--required false \
|
||||
--size 100
|
||||
|
||||
# Indexes erstellen
|
||||
appwrite databases createIndex \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key idx_account_id \
|
||||
--type key \
|
||||
--attributes product_account_id
|
||||
|
||||
appwrite databases createIndex \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key idx_platform_product_id \
|
||||
--type unique \
|
||||
--attributes product_platform_product_id
|
||||
|
||||
appwrite databases createIndex \
|
||||
--database-id eship-db \
|
||||
--collection-id products \
|
||||
--key idx_account_created \
|
||||
--type key \
|
||||
--attributes product_account_id $createdAt
|
||||
```
|
||||
|
||||
## Zusammenfassung
|
||||
|
||||
**Erforderliche Attribute (Required):**
|
||||
1. `product_account_id` (String)
|
||||
2. `product_platform` (Enum: ["amazon", "ebay"])
|
||||
3. `product_platform_market` (String)
|
||||
4. `product_platform_product_id` (String, Unique)
|
||||
|
||||
**Optionale Attribute:**
|
||||
5. `product_title` (String)
|
||||
6. `product_price` (Float)
|
||||
7. `product_currency` (String)
|
||||
8. `product_url` (String)
|
||||
9. `product_status` (Enum: ["active", "ended", "unknown"])
|
||||
10. `product_category` (String)
|
||||
11. `product_condition` (String)
|
||||
|
||||
**Standard-Felder (automatisch):**
|
||||
- `$id` (String)
|
||||
- `$createdAt` (DateTime)
|
||||
- `$updatedAt` (DateTime)
|
||||
Reference in New Issue
Block a user