2.1.8 • Published 5 years ago

@muzikanto/pg v2.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

PostgresSQl

Fast create sql query

  • Connect
const db = new DB('ssh');
or
const db = new DB(new Pool({/* config */}));
  • Standart
db.promise('sql query')
  • Table
const users = db.table<{ id: string, name: string, age: string }>('users');
  • .send() return Promise rows result
  • and all other keys return string

  • Create Table

users
    .create({
        id: 'bigint',
        name: 'varchar(100)',
        age: 'int',
        company_id: 'bigint',
        }, 
        ['FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE']
    ).send();
  • Drop Table
table('users')
    .drop()
    .send();
  • Insert
users
    .insert({id: 'id', name: 'Max', surname: undefined}) // ignore surname field
    .send();
  • Select
users
    .select(['users.id', 'test2.name'])
    .join('left join test2 on test2.id = users.id')
    .where('users.id = 2')
    .order('users.id')
    .limit(5)
    .offset(12)
    .send();
  • Update
users
    .update({id: 'id', name: 'Max', surname: undefined}) // ignore surname field
    .join('left join company on company.id = users.id')
    .where('users.id = 2')
    .order('users.id')
    .limit(5)
    .offset(12)
    .send();
  • Delete
users
    .deletes()
    .join('left join company on company.id = users.id')
    .where('users.id = 2 and company.id = 3')
    .order('users.id')
    .limit(5)
    .offset(12)
    .send();
2.1.8

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.0

5 years ago