mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-19 00:26:34 +08:00
Updated to Massive v4 (#22594)
* Updated to Massive v4 * Update tsconfig.json * Remove white space
This commit is contained in:
committed by
Mohamed Hegazy
parent
60eb4d9ea2
commit
e73a94c7ec
2
types/massive/index.d.ts
vendored
2
types/massive/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for massive 3.0
|
||||
// Type definitions for massive 4.0
|
||||
// Project: https://github.com/dmfay/massive-js.git
|
||||
// Definitions by: Pascal Birchler <https://github.com/swissspidy>
|
||||
// Clarence Ho <https://github.com/clarenceh>
|
||||
|
||||
82
types/massive/v3/index.d.ts
vendored
Normal file
82
types/massive/v3/index.d.ts
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
// Type definitions for massive 3.0
|
||||
// Project: https://github.com/dmfay/massive-js.git
|
||||
// Definitions by: Pascal Birchler <https://github.com/swissspidy>
|
||||
// Clarence Ho <https://github.com/clarenceh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export = massive;
|
||||
|
||||
declare function massive(
|
||||
connection: massive.ConnectionInfo | string,
|
||||
loaderConfig?: object,
|
||||
driverConfig?: object): Promise<massive.Database>;
|
||||
|
||||
declare namespace massive {
|
||||
interface ConnectionInfo {
|
||||
user?: string;
|
||||
database?: string;
|
||||
password?: string | null;
|
||||
port?: number;
|
||||
host?: string;
|
||||
ssl?: boolean;
|
||||
application_name?: string;
|
||||
fallback_application_name?: boolean;
|
||||
}
|
||||
|
||||
interface QueryOptions {
|
||||
columns?: string[];
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
only?: boolean;
|
||||
order?: string[];
|
||||
orderBody?: boolean;
|
||||
build?: boolean;
|
||||
document?: boolean;
|
||||
single?: boolean;
|
||||
stream?: boolean;
|
||||
}
|
||||
|
||||
interface SearchCriteria {
|
||||
fields: string[];
|
||||
term: string;
|
||||
}
|
||||
|
||||
interface Table<T> {
|
||||
find(criteria: object | {}, queryOptions?: QueryOptions): Promise<T[]>;
|
||||
findOne(criteria: number | object, queryOptions?: QueryOptions): Promise<T>;
|
||||
count(criteria: object): Promise<string>;
|
||||
where(query: string, params: any[] | object): Promise<T[]>;
|
||||
search(criteria: SearchCriteria, queryOptions?: QueryOptions): Promise<any>;
|
||||
save(data: object): Promise<T>;
|
||||
insert(data: object): Promise<T>;
|
||||
insert(data: object[]): Promise<T[]>;
|
||||
update(dataOrCriteria: object, changesMap?: object): Promise<T>;
|
||||
update(dataOrCriteria: object[], changesMap?: object): Promise<T[]>;
|
||||
destroy(criteria: object): Promise<T[]>;
|
||||
}
|
||||
|
||||
interface Document {
|
||||
countDoc(criteria: object): Promise<number>;
|
||||
findDoc(criteria: number | string| object): Promise<object>;
|
||||
searchDoc(criteria: SearchCriteria): Promise<object[]>;
|
||||
saveDoc(doc: object): Promise<object>;
|
||||
modify(docId: number | string, doc: object, fieldName?: string): Promise<object>;
|
||||
}
|
||||
|
||||
interface Database {
|
||||
attach(ctor: any, ...sources: any[]): Promise<any>;
|
||||
detach(entity: string, collection: string): void;
|
||||
reload(): void;
|
||||
query(query: any, params: any, options: any): Promise<any>;
|
||||
saveDoc(collectionName: string, doc: object): Promise<any>;
|
||||
createDocumentTable(path: any): Promise<any>;
|
||||
getObject(path: any, collection: any): object;
|
||||
dropTable(table: string, options: any): void;
|
||||
createSchema(schemaName: string): void;
|
||||
dropSchema(schemaName: string, options: any): void;
|
||||
run(query: string, params: any[] | object): Promise<object[]>;
|
||||
}
|
||||
}
|
||||
10
types/massive/v3/massive-tests.ts
Normal file
10
types/massive/v3/massive-tests.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import massive = require('massive');
|
||||
|
||||
let dbconn: massive.Database;
|
||||
|
||||
massive('postgres://app:password@localhost:5432/app').then(db => {
|
||||
console.log(`DB connected successfully`);
|
||||
dbconn = db;
|
||||
}).catch(err => {
|
||||
console.error(`Error connecting DB`);
|
||||
});
|
||||
26
types/massive/v3/tsconfig.json
Normal file
26
types/massive/v3/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"massive": [ "massive/v3" ]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"massive-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/massive/v3/tslint.json
Normal file
1
types/massive/v3/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user