myorm2001
TypeScript icon, indicating that this package has built-in type declarations

2.5.1 • Public • Published

npm install soul-orm

    const users =  await db.table('user').where({ name: 'jake' }).order('age', 'desc').select();
    const users = await db.table('user').where('name = ?', ['jake']).limit(10, 20).select();
    const user = await db.table('user').where({ name: 'jake' }).field('name', 'age').find();
    const user = await db.table('user').where({ name: 'jake' }).findOrEmpty();
    // insert
    await db.table('user').insert({ name: 'jake', age: '22' });
    await db.table('user').insert([{ name: 'jake', age: '22' }, { name: 'jake', age: '22' }]);
    // update
    await db.table('user').where({ name: 'jake' }).update({ name: 'new name' });
    // delete
    await db.table('user').where({ name: 'jake' }).delete();
    // transaction
    const tx = await db.beginTx();
    try {
      await tx.table('user').insert({ name: 'jake' });
      await tx.table('user').where({ name: 'jake' }).update({ name: 'new name' });
      await tx.commit();
    } catch (error) {
      await tx.rollback();
    }
    // row query
    const result = await db.query(`SELECT * FROM user U LEFT JOIN user_roles UR ON UR.user_id = U.id WHERE U.type = ?`, ['type']);

Readme

Keywords

Package Sidebar

Install

npm i myorm2001

Weekly Downloads

1

Version

2.5.1

License

ISC

Unpacked Size

46.3 kB

Total Files

25

Last publish

Collaborators

  • cvnhjiouuhha761