@monkeyplus/unorm
v0.5.14
Published
Universal Orm Layer
Downloads
32
Readme
Unorm
Herramienta para capa de datos
Uso
# yarn
yarn add @monkeyplus/unorm
# npm
npm install @monkeyplus/unorm
# pnpm
pnpm add @monkeyplus/unorm
Ejemplo
import { createOrm } from '@monkeyplus/unorm';
import { defineDriver } from '@monkeyplus/unorm/drivers/knex';
const driver = defineDriver(/* ...options */);
const orm = createOrm({ driver });
const User = orm.defineModel('users', {
fields: ['id', 'name', 'email'],
});
// Create User
const user = await User.create({ name: 'John Doe', email: '[email protected]' });
// Update UserByPk
const user = await User.updateByPk(1, { name: 'John Doe', email: '' });
// Delete UserByPk
const user = await User.deleteByPk(1);
// Find UserByPk
const user = await User.findByPk(1);
// FindAll
const users = await User.findAll();