0.1.2 • Published 3 years ago

@unicreators/sql-parser v0.1.2

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

Tests npm (scoped) License

sql-parser is a library that converts expressions into T-SQL.

sql-parser 是一个将表达式转换为 T-SQL 的库。

import { $select, $gt, $and, $startsWith } from '@unicreators/sql-parser';
let { sql, values } = $select('users', {
    selection: [{ column: 'col1', alias: 'age' }, 'col2'],
    where: $and($gt('col1', 20), $startsWith('col2', 'yichen'))
});
expect(sql).equal('SELECT col1 AS age, col2 FROM users WHERE (col1 > ?) AND (col2 LIKE ?)');
expect(values).deep.equal([20, 'yichen%']);

:watermelon: Example

Install

$ npm install @unicreators/sql-parser

Operators

  • $select
  • $update
  • $insert
  • $delete
  • $and
  • $or
  • $eq
  • $ne
  • $gt
  • $gte
  • $lt
  • $lte
  • $contains
  • $startsWith
  • $endsWith
  • $in
  • $limit
  • $assign
  • $min
  • $max
  • $sum
  • $count
  • $groupby
  • $orderby
  • $table
  • $column
  • $value
  • $alias

License

MIT