Drizzle ORM ve SQLite veritabanı yönetimi. Schema, migration, query, useLiveQuery. Use when working with src/db/, schema.ts, migrations, or database queries in Money Expo.
Drizzle ORM ve SQLite veritabanı yönetimi için Money Expo domain uzmanı.
expo-sqlite — SQLitedrizzle-orm — ORMdrizzle-kit — Migrationimport { useLiveQuery } from 'drizzle-orm/expo-sqlite';
function useCategories() {
const db = useSQLiteContext();
const drizzleDb = drizzle(db, { schema });
const { data } = useLiveQuery(
drizzleDb.select().from(schema.categories)
);
return data;
}
async function getTransactionsWithDetails(db: DrizzleDB, periodKey: string) {
return db.select({
id: schema.paymentTransactions.id,
amount: schema.paymentTransactions.amount,
isPaid: schema.paymentTransactions.isPaid,
title: schema.payments.title,
type: schema.payments.type,
categoryName: schema.categories.name,
categoryColor: schema.categories.color,
categoryIcon: schema.categories.icon,
})
.from(schema.paymentTransactions)
.leftJoin(schema.payments, eq(schema.paymentTransactions.paymentId, schema.payments.id))
.leftJoin(schema.categories, eq(schema.payments.categoryId, schema.categories.id))
.where(eq(schema.paymentTransactions.periodKey, periodKey));
}
npx drizzle-kit generate # Schema değişikliğinden sonra
npx drizzle-kit push # Geliştirme ortamında
npx drizzle-kit studio # Veritabanı görüntüleme
export const payments = sqliteTable('payments', {
id: integer('id').primaryKey({ autoIncrement: true }),
title: text('title').notNull(),
});
export type Payment = typeof payments.$inferSelect;
export type NewPayment = typeof payments.$inferInsert;
Temel katman — başka agent'a bağımlı değil.
useLiveQuery sadece gerçek zamanlı güncelleme gereken listelerde kullan