mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Merge pull request #30260 from q42jaap/master
Adds type definitions for sql-template npm package
This commit is contained in:
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// Type definitions for sql-template 1.2
|
||||
// Project: https://github.com/131/sql-template
|
||||
// Definitions by: Jaap Taal <https://github.com/q42jaap>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export = SQL;
|
||||
declare function SQL(parts: TemplateStringsArray, ...values: any[]): SQL.Fragment;
|
||||
|
||||
declare namespace SQL {
|
||||
interface Fragment {
|
||||
raw: string;
|
||||
text: string;
|
||||
values?: any[];
|
||||
}
|
||||
|
||||
type ChainFn = (values: any[], part: string) => string;
|
||||
|
||||
type Transformer = (values: any[], str: string, chain: ChainFn) => void;
|
||||
|
||||
function insert(table: string, values: object): Fragment;
|
||||
function insert_bulk(table: string, keys: string[], values: any[][]): Fragment;
|
||||
function update(table: string, values: object, where?: any): Fragment;
|
||||
function select(table: string, where?: any, cols?: string, extra?: string): Fragment;
|
||||
function search_blob(search_field: string, qs: string, main_field?: string, LIKE?: string): Fragment | false;
|
||||
|
||||
const transformers: {[key: string]: Transformer};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import SQL = require("sql-template");
|
||||
|
||||
const query = SQL`INSERT INTO table (column) VALUES (${"value"})`;
|
||||
SQL.transformers["in"]([], "", () => "");
|
||||
|
||||
SQL.insert("table", {column: "value"});
|
||||
SQL.insert_bulk("table", ["column"], [["value"]]);
|
||||
|
||||
SQL.update("table", {column: "value"});
|
||||
SQL.update("table", {column: "value"}, true);
|
||||
SQL.update("table", {column: "value2"}, {column: "value1"});
|
||||
SQL.update("table", {column: "value2"}, SQL`column = ${"value1"}`);
|
||||
|
||||
SQL.select("table");
|
||||
SQL.select("table", {column: "value"});
|
||||
SQL.select("table", {column: "value"}, "a, b");
|
||||
SQL.select("table", {column: "value"}, "a, b", "GROUP BY x");
|
||||
|
||||
SQL.search_blob("column", "value");
|
||||
SQL.search_blob("column", "value #1", "user_id");
|
||||
SQL.search_blob("column", "value #1", "user_id", "LIKE");
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"sql-template-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user