-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Carlos Lopez edited this page Jul 16, 2026
·
1 revision
Tutorial rápido para comenzar con GitDB en 5 minutos.
import { entity, uuid, text, int, timestamp } from '@kettu/gitdb';
export const User = entity('users', {
id: uuid().primary(),
email: text().unique(),
name: text(),
age: int(),
createdAt: timestamp()
});import { gitDb } from '@kettu/gitdb';
const db = await gitDb({
dir: './data',
author: {
name: 'My App',
email: 'app@example.com'
}
});const user = await db.insert(User).values({
id: 'uuid-1',
email: 'john@example.com',
name: 'John Doe',
age: 30,
createdAt: new Date()
});// Obtener todos
const allUsers = await db.select().from(User);
// Con filtros
const adults = await db
.select()
.from(User)
.where(gte('age', 18));
// Campos específicos
const emails = await db
.select(['email', 'name'])
.from(User);await db
.update(User)
.set({ name: 'Jane Doe' })
.where(eq('id', 'uuid-1'));await db
.delete()
.from(User)
.where(eq('id', 'uuid-1'));await db.close();import { gitDb, entity, uuid, text, int, timestamp, eq, gte } from '@kettu/gitdb';
const User = entity('users', {
id: uuid().primary(),
email: text().unique(),
name: text(),
age: int(),
createdAt: timestamp()
});
async function main() {
const db = await gitDb({
dir: './data',
author: {
name: 'My App',
email: 'app@example.com'
}
});
// Insert
await db.insert(User).values({
id: '1',
email: 'john@example.com',
name: 'John',
age: 30,
createdAt: new Date()
});
// Select
const users = await db.select().from(User);
console.log(users);
// Update
await db.update(User).set({ age: 31 }).where(eq('id', '1'));
// Delete
await db.delete().from(User).where(eq('id', '1'));
await db.close();
}
main().catch(console.error);- Schema Documentation - Tipos disponibles
- Query API - Operaciones avanzadas
- Operators - Filtros WHERE