2016-12-08 13:47:09 +01:00
|
|
|
import express = require("express");
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
declare namespace Sails {
|
|
|
|
import Request = express.Request;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export interface Application {}
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export interface Model {
|
|
|
|
attributes: Object;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
create(params: Object): WaterlinePromise<QueryResult>;
|
|
|
|
create(params: Array<Object>): WaterlinePromise<QueryResult>;
|
|
|
|
create(params: Object, cb: (err: Error, created: QueryResult)=>void): void;
|
|
|
|
create(params: Array<Object>, cb: (err: Error, created: Array<QueryResult>)=>void): void;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
find(): QueryBuilder;
|
|
|
|
find(params: Object): QueryBuilder;
|
|
|
|
find(params: Object): WaterlinePromise<Array<QueryResult>>;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
findOne(criteria: Object): WaterlinePromise<QueryResult>;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
count(criteria: Object): WaterlinePromise<number>;
|
|
|
|
count(criteria: Array<Object>): WaterlinePromise<number>;
|
|
|
|
count(criteria: string): WaterlinePromise<number>;
|
|
|
|
count(criteria: number): WaterlinePromise<number>;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
count(criteria: Object, cb: (err: Error, found: number)=>void);
|
|
|
|
count(criteria: Array<Object>, cb: (err: Error, found: number)=>void);
|
|
|
|
count(criteria: string, cb: (err: Error, found: number)=>void);
|
|
|
|
count(criteria: number, cb: (err: Error, found: number)=>void);
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
destroy(criteria: Object): WaterlinePromise<Array<Record>>;
|
|
|
|
destroy(criteria: Array<Object>): WaterlinePromise<Array<Record>>;
|
|
|
|
destroy(criteria: string): WaterlinePromise<Array<Record>>;
|
|
|
|
destroy(criteria: number): WaterlinePromise<Array<Record>>;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
destroy(criteria: Object, cb: (err: Error, deleted: Array<Record>)=>void): void;
|
|
|
|
destroy(criteria: Array<Object>, cb: (err: Error, deleted: Array<Record>)=>void): void;
|
|
|
|
destroy(criteria: string, cb: (err: Error, deleted: Array<Record>)=>void): void;
|
|
|
|
destroy(criteria: number, cb: (err: Error, deleted: Array<Record>)=>void): void;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
update(criteria: Object, changes: Object): WaterlinePromise<Array<QueryResult>>;
|
|
|
|
update(criteria: Array<Object>, changes: Object): WaterlinePromise<Array<QueryResult>>;
|
|
|
|
update(criteria: string, changes: Object): WaterlinePromise<Array<QueryResult>>;
|
|
|
|
update(criteria: number, changes: Object): WaterlinePromise<Array<QueryResult>>;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
update(criteria: Object, changes: Array<Object>): WaterlinePromise<Array<QueryResult>>;
|
|
|
|
update(criteria: Array<Object>, changes: Array<Object>): WaterlinePromise<Array<QueryResult>>;
|
|
|
|
update(criteria: string, changes: Array<Object>): WaterlinePromise<Array<QueryResult>>;
|
|
|
|
update(criteria: number, changes: Array<Object>): WaterlinePromise<Array<QueryResult>>;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
update(criteria: Object, changes: Array<Object>, cb: (err: Error, updated: Array<QueryResult>)=>void): void;
|
|
|
|
update(criteria: Array<Object>, changes: Array<Object>, cb: (err: Error, updated: Array<QueryResult>)=>void): void;
|
|
|
|
update(criteria: string, changes: Array<Object>, cb: (err: Error, updated: Array<QueryResult>)=>void): void;
|
|
|
|
update(criteria: number, changes: Array<Object>, cb: (err: Error, updated: Array<QueryResult>)=>void): void;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
query(sqlQuery: string, cb: (err: Error, results: Array<Record>)=>void);
|
|
|
|
native(cb: (err: Error, collection: Model)=>void);
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
stream(criteria: Object, writeEnd: Object): NodeJS.WritableStream;
|
|
|
|
stream(criteria: Array<Object>, writeEnd: Object): NodeJS.WritableStream;
|
|
|
|
stream(criteria: string, writeEnd: Object): NodeJS.WritableStream;
|
|
|
|
stream(criteria: number, writeEnd: Object): NodeJS.WritableStream;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
stream(criteria: Object, writeEnd: Object): Error;
|
|
|
|
stream(criteria: Array<Object>, writeEnd: Object): Error;
|
|
|
|
stream(criteria: string, writeEnd: Object): Error;
|
|
|
|
stream(criteria: number, writeEnd: Object): Error;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
}
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export interface Req extends express.Request { }
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export interface Res extends express.Response {
|
|
|
|
attachement(filename:string);
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
badRequest();
|
|
|
|
badRequest(data:any);
|
|
|
|
badRequest(data:any, pathToView:string);
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
serverError();
|
|
|
|
serverError(data:any);
|
|
|
|
serverError(data:any, pathToView:string);
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
view(route: string);
|
|
|
|
}
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export class WaterlinePromise<T> extends Promise<T> {
|
|
|
|
exec(cb: (err: Error, results: Array<QueryResult>)=>void);
|
|
|
|
exec(cb: (err: Error, result: QueryResult)=>void);
|
|
|
|
}
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export class Record {
|
|
|
|
id: number;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
}
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export class QueryResult extends Record {
|
|
|
|
destroy(): Promise<Array<Sails.QueryResult>>;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
toJSON(): Object;
|
|
|
|
}
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export class QueryBuilder extends Promise<any> {
|
|
|
|
exec(cb: (error: any, results: Array<QueryResult>)=>void);
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
where(condition: Object): QueryBuilder;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
limit(lim: number): QueryBuilder;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
skip(num: number): QueryBuilder;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
sort(criteria: string): QueryBuilder;
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
populate(association: string): QueryBuilder;
|
|
|
|
populate(association: string, filter: Object): QueryBuilder;
|
|
|
|
}
|
2015-03-21 23:21:19 +01:00
|
|
|
|
2016-12-08 13:47:09 +01:00
|
|
|
export interface Controller {}
|
2015-03-21 23:21:19 +01:00
|
|
|
}
|