Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "Lightweight SQL query builder",
"module": "dist/sqliterally.mjs",
"main": "dist/sqliterally.js",
"types": "types/index.d.ts",
"license": "MIT",
"author": {
"name": "Terkel Gjervig",
Expand All @@ -21,7 +22,8 @@
"prepublish": "npm run build"
},
"files": [
"dist"
"dist",
"types"
Copy link
Copy Markdown
Owner

@terkelg terkelg Aug 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do "*.d.ts", and place the types in the root of the project as sqliterally.d.ts?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could. I'll do that in the next iteration.

Related the where to place them (@types or here), it should be here. @types if for when a package doesn't include itself

],
"keywords": [
"db",
Expand Down
42 changes: 42 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
interface Literal {
pieces: any[];
values: any[];
delimiter: string;
text: string;
sql: string;
constructor(pieces?: string[], values?: any[], delimiter?: string);
clone(): Literal;
append(literal: string | Literal, delimiter?: string): Literal;
prefix(string?: string): Literal;
suffix(string?: string): Literal;
}

declare class Query {
constructor(clauses?: any[]);

build(delimited?: string): Literal;

select(pieces: string, ...values: any[]): Query;
update(pieces: string, ...values: any[]): Query;
set(pieces: string, ...values: any[]): Query;
from(pieces: string, ...values: any[]): Query;
join(pieces: string, ...values: any[]): Query;
leftJoin(pieces: string, ...values: any[]): Query;
where(pieces: string, ...values: any[]): Query;
orWhere(pieces: string, ...values: any[]): Query;
having(pieces: string, ...values: any[]): Query;
orHaving(pieces: string, ...values: any[]): Query;
groupBy(pieces: string, ...values: any[]): Query;
orderBy(pieces: string, ...values: any[]): Query;
update(pieces: string, ...values: any[]): Query;
limit(pieces: string, ...values: any[]): Query;
returning(pieces: string, ...values: any[]): Query;
lockInShareMode: Query;
forUpdate: Query;
}

export const query: Query;

type Sql = (pieces: string, ...values: any[]) => Literal;

export const sql: Sql;