Consultas
Consultas
Section titled “Consultas”jsorm usa una forma estructurada de consulta en lugar de chain builders.
Select
Section titled “Select”const result = await db.get(User, { select: { id: true, name: true, role: { name: true, }, }, where: { active: true, name: { contains: 'Ali', }, }, orderBy: [{ createdAt: 'desc' }], pagination: { limit: 10, offset: 0, },});Update
Section titled “Update”await db.update(User, { data: { active: false, }, where: { role: { name: { eq: 'guest', }, }, },});Delete
Section titled “Delete”await db.delete(User, { where: { id: { eq: 10, }, },});Buenas prácticas
Section titled “Buenas prácticas”- Mantén cláusulas
whereexplícitas para escrituras. - Prefiere filtros de relación anidados en lugar de joins raw.
- Usa
orderByypaginationjuntos para endpoints estables.