# Dexie IndexedDB - FikoYT

## 💾 Local Database

**FikoDexieDatabase:**
```typescript
export class FikoDexieDatabase extends Dexie {
  settings!: Table<Setting>;
  drawings!: Table<Drawing>;

  constructor() {
    super("FikoYT-Sistem");
    this.version(1).stores({
      settings: '++id, key, value',
      drawings: '++id, name, created'
    });
  }
}
```

## 📋 CRUD Operations

**Create/Update:**
```typescript
await db.ekleYadaGuncelleTek(data, "key");
```

**Read:**
```typescript
const data = await db.getByPrimaryKey("key");
const all = await db.toArray();
```

**Delete:**
```typescript
await db.delete("id");
await db.clear();
```

## 🔄 Sync Pattern

**Local → Server:**
```typescript
// Local'e kaydet
await localDB.save(data);

// Server'a gönder
await api.post('/sync', data);
```

**Server → Local:**
```typescript
// Server'dan al
const data = await api.get('/data');

// Local'e yaz
await localDB.bulkPut(data);
```

## ⚡ Performans

- **Index:** Fast queries
- **Transactions:** Atomic operations
- **Bulk:** Batch operations
- **Cache:** In-memory cache

---
2025-11-06