Skip to content
Merged
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
27 changes: 27 additions & 0 deletions lib/TypeScript/orm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare module "orm" {

import events = require('events');
import sqlquery = require('sqlquery');

module orm {

Expand All @@ -26,6 +27,7 @@ declare module "orm" {
order?: any;
}, callback: (err: Error, results: Instance[]) => void): Model;
find(conditions: { [property: string]: any }, limit: number, order: string[], callback: (err: Error, results: Instance[]) => void): Model;
find(conditions: { [property: string]: any }): IChainFind;

all(conditions: { [property: string]: any }, callback: (err: Error, results: Instance[]) => void): Model;
all(conditions: { [property: string]: any }, options: {
Expand Down Expand Up @@ -123,6 +125,22 @@ declare module "orm" {
get(callback: (err: Error, instance: Instance) => void);
}

export interface IChainFind {
find(conditions: { [property: string]: any }): IChainFind;
only(...args: string[]): IChainFind;
limit(limit: number): IChainFind;
offset(offset: number): IChainFind;
run(callback: (err: Error, results: Instance[]) => void): void;
count(callback: (err: Error, count: number) => void): void;
remove(callback: (err: Error) => void): void;
save(callback: (err: Error) => void): void;
each(callback: (result: Instance) => void): void;
each(): IChainFind;
filter(callback: (result: Instance) => boolean): IChainFind;
sort(callback: (a: Instance, b: Instance) => boolean): IChainFind;
get(callback: (results: Instance[]) => void): IChainFind;
}

/*
* Classes
*/
Expand Down Expand Up @@ -234,6 +252,15 @@ declare module "orm" {
}

export function Text(type: string): sqlquery.TextQuery;
export function eq(value: any): sqlquery.Comparator;
export function ne(value: any): sqlquery.Comparator;
export function gt(value: any): sqlquery.Comparator;
export function gte(value: any): sqlquery.Comparator;
export function lt(value: any): sqlquery.Comparator;
export function lte(value: any): sqlquery.Comparator;
export function like(value: string): sqlquery.Comparator;
export function between(a: number, b: number): sqlquery.Comparator;
export function not_between(a: number, b: number): sqlquery.Comparator;
export function express(uri: string, handlers: {
define(db: ORM, models: { [key: string]: Model });
}): (req, res, next) => void;
Expand Down
135 changes: 69 additions & 66 deletions lib/TypeScript/sql-query.d.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,79 @@
declare module sqlquery {
export class Query {
constructor(dialect: string);
constructor(options: {
dialect: string;
});
static Text(type: string): TextQuery;
declare module "sqlquery" {
module sqlquery {
export class Query {
constructor(dialect: string);
constructor(options: {
dialect: string;
});
static Text(type: string): TextQuery;

static Comparators: string[];
static between(a: number, b: number): Comparator;
static not_between(a: number, b: number): Comparator;
static like(expression: string): Comparator;
static eq(value: any): Comparator;
static ne(value: any): Comparator;
static gt(value: any): Comparator;
static gte(value: any): Comparator;
static lt(value: any): Comparator;
static lte(value: any): Comparator;
static Comparators: string[];
static between(a: number, b: number): Comparator;
static not_between(a: number, b: number): Comparator;
static like(expression: string): Comparator;
static eq(value: any): Comparator;
static ne(value: any): Comparator;
static gt(value: any): Comparator;
static gte(value: any): Comparator;
static lt(value: any): Comparator;
static lte(value: any): Comparator;

escapeId(id: string): string;
escapeId(id: string, table: string): string;
escapeVal(value: any): string;
select(): SelectQuery;
insert(): InsertQuery;
update(): UpdateQuery;
remove(): RemoveQuery;
}
escapeId(id: string): string;
escapeId(id: string, table: string): string;
escapeVal(value: any): string;
select(): SelectQuery;
insert(): InsertQuery;
update(): UpdateQuery;
remove(): RemoveQuery;
}

export interface Comparator {
sql_comparator(): string;
from?: any;
to?: any;
expr?: string;
value?: any;
}
export interface Comparator {
sql_comparator(): string;
from?: any;
to?: any;
expr?: string;
value?: any;
}

export interface TextQuery {
data: any;
type: string;
}
export interface TextQuery {
data: any;
type: string;
}

export interface SelectQuery {
select(fields: string): SelectQuery;
calculateFoundRows: SelectQuery;
as(alias: string): SelectQuery;
fun(fun: string, column: string, alias: string): SelectQuery;
from(table: string, from_id: string, to_id: string): SelectQuery;
from(table: string, from_id: string, to_table: string, to_id: string): SelectQuery;
where(...args: any[]): SelectQuery;
whereExists(table: string, table_link: string, link: string, conditions: { [column: string]: any }): SelectQuery;
groupBy(...columns: string[]): SelectQuery;
offset(offset: number): SelectQuery;
limit(limit: number): SelectQuery;
order(column: string, direction: string): SelectQuery;
build(): string;
}
export interface SelectQuery {
select(fields: string): SelectQuery;
calculateFoundRows: SelectQuery;
as(alias: string): SelectQuery;
fun(fun: string, column: string, alias: string): SelectQuery;
from(table: string, from_id: string, to_id: string): SelectQuery;
from(table: string, from_id: string, to_table: string, to_id: string): SelectQuery;
where(...args: any[]): SelectQuery;
whereExists(table: string, table_link: string, link: string, conditions: { [column: string]: any }): SelectQuery;
groupBy(...columns: string[]): SelectQuery;
offset(offset: number): SelectQuery;
limit(limit: number): SelectQuery;
order(column: string, direction: string): SelectQuery;
build(): string;
}

export interface InsertQuery {
into(table: string): InsertQuery;
set(values: { [key: string]: any }[]): InsertQuery;
build(): string;
}
export interface InsertQuery {
into(table: string): InsertQuery;
set(values: { [key: string]: any }[]): InsertQuery;
build(): string;
}

export interface UpdateQuery {
into(table: string): UpdateQuery;
set(values: { [column: string]: any }): UpdateQuery;
where(...conditions: { [column: string]: any }[]): UpdateQuery;
build(): string;
}
export interface UpdateQuery {
into(table: string): UpdateQuery;
set(values: { [column: string]: any }): UpdateQuery;
where(...conditions: { [column: string]: any }[]): UpdateQuery;
build(): string;
}

export interface RemoveQuery {
from(table: string): RemoveQuery;
where(...conditions: { [column: string]: any }[]): RemoveQuery;
build(): string;
export interface RemoveQuery {
from(table: string): RemoveQuery;
where(...conditions: { [column: string]: any }[]): RemoveQuery;
build(): string;
}
}
export = sqlquery;
}