querie
SQL query builder
Last updated 2 years ago by andrejewski .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install querie 
SYNC missed versions from official npm registry.

Querie

SQL query builder

Construct queries to pass to node-postgres query().

This library uses sql-template-strings to build query statement objects.

Example

import { createQuery } from 'querie'

const bluePeopleInsert = createQuery({
  kind: 'insert',
  table: 'people',
  values: [
    { name: 'Chris', color: 'blue' },
    { name: 'Kevin', color: 'blue' }
  ]
})
// => insert into people (name, color) values ('Chris', 'blue'), ('Kevin', 'blue')

const bluePeopleSelect = createQuery({
  kind: 'select',
  table: 'people',
  columns: ['name', 'age'],
  where: {
    color: ['=', 'blue']
  }
})
// => select name, age from people where color = 'blue'

const bluePeopleUpdate = createQuery({
  kind: 'update',
  table: 'people',
  set: {
    color: 'green'
  },
  where: {
    color: ['=', 'blue']
  }
})
// => update people set color = 'green' where color = 'blue'

Features

  • State and side-effect free query building.
    Queries are built without knowledge of or connection to a database.

  • Data driven queries
    Queries are built using plain JavaScript data structures, no method chaining.

  • Column aliases
    Alias JS friendly column names to what is in the database seamlessly.

Current Tags

  • 0.0.5                                ...           latest (2 years ago)

5 Versions

  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |