mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
* Renamed property according with docs
* Moved types to other file
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import Database = require('better-sqlite3');
|
||||
import { RunResult } from 'better-sqlite3/types';
|
||||
|
||||
const integer = Database.Integer(1);
|
||||
const err = new Database.SqliteError('ok', 'ok');
|
||||
const result: RunResult = { changes: 1, lastInsertRowid: 1 };
|
||||
|
||||
let db = Database('.');
|
||||
db = new Database('.', {memory: true});
|
||||
|
||||
84
types/better-sqlite3/index.d.ts
vendored
84
types/better-sqlite3/index.d.ts
vendored
@@ -1,89 +1,11 @@
|
||||
// Type definitions for better-sqlite3 3.1
|
||||
// Type definitions for better-sqlite3 5.0
|
||||
// Project: http://github.com/JoshuaWise/better-sqlite3
|
||||
// Definitions by: Ben Davies <https://github.com/Morfent>
|
||||
// Mathew Rumsey <https://github.com/matrumz>
|
||||
// Santiago Aguilar <https://github.com/sant123>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import Integer = require('integer');
|
||||
|
||||
interface RunResult {
|
||||
changes: number;
|
||||
lastInsertROWID: Integer.IntLike;
|
||||
}
|
||||
|
||||
declare class Statement {
|
||||
database: Database;
|
||||
source: string;
|
||||
returnsData: boolean;
|
||||
constructor(db: Database, sources: string[]);
|
||||
|
||||
run(...params: any[]): RunResult;
|
||||
get(...params: any[]): any;
|
||||
all(...params: any[]): any[];
|
||||
each(params: any, cb: (row: any) => void): void;
|
||||
each(cb: (row: any) => void): void;
|
||||
each(...params: any[]): void;
|
||||
pluck(toggleState?: boolean): this;
|
||||
bind(...params: any[]): this;
|
||||
safeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
|
||||
declare class Transaction {
|
||||
database: Database;
|
||||
source: string;
|
||||
constructor(db: Database, sources: string[]);
|
||||
|
||||
run(...params: any[]): RunResult;
|
||||
bind(...params: any[]): this;
|
||||
safeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
|
||||
interface DatabaseOptions {
|
||||
memory?: boolean;
|
||||
readonly?: boolean;
|
||||
fileMustExist?: boolean;
|
||||
}
|
||||
|
||||
interface RegistrationOptions {
|
||||
name?: string;
|
||||
varargs?: boolean;
|
||||
deterministic?: boolean;
|
||||
safeIntegers?: boolean;
|
||||
}
|
||||
|
||||
interface Database {
|
||||
memory: boolean;
|
||||
readonly: boolean;
|
||||
name: string;
|
||||
open: boolean;
|
||||
inTransaction: boolean;
|
||||
|
||||
prepare(source: string): Statement;
|
||||
transaction(sources: string[]): Transaction;
|
||||
exec(source: string): this;
|
||||
pragma(source: string, simplify?: boolean): any;
|
||||
checkpoint(databaseName?: string): this;
|
||||
register(cb: (...params: any[]) => any): this;
|
||||
register(options: RegistrationOptions, cb: (...params: any[]) => any): this;
|
||||
close(): this;
|
||||
defaultSafeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
|
||||
declare class SqliteError implements Error {
|
||||
name: string;
|
||||
message: string;
|
||||
code: string;
|
||||
constructor(message: string, code: string);
|
||||
}
|
||||
|
||||
interface DatabaseConstructor {
|
||||
new(filename: string, options?: DatabaseOptions): Database;
|
||||
(filename: string, options?: DatabaseOptions): Database;
|
||||
prototype: Database;
|
||||
|
||||
Integer: typeof Integer;
|
||||
SqliteError: typeof SqliteError;
|
||||
}
|
||||
import { DatabaseConstructor } from "./types";
|
||||
|
||||
declare const Database: DatabaseConstructor;
|
||||
export = Database;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"types.d.ts",
|
||||
"better-sqlite3-tests.ts"
|
||||
]
|
||||
}
|
||||
80
types/better-sqlite3/types.d.ts
vendored
Normal file
80
types/better-sqlite3/types.d.ts
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import Integer = require("integer");
|
||||
|
||||
export interface RunResult {
|
||||
changes: number;
|
||||
lastInsertRowid: Integer.IntLike;
|
||||
}
|
||||
|
||||
export class Statement {
|
||||
database: Database;
|
||||
source: string;
|
||||
returnsData: boolean;
|
||||
constructor(db: Database, sources: string[]);
|
||||
|
||||
run(...params: any[]): RunResult;
|
||||
get(...params: any[]): any;
|
||||
all(...params: any[]): any[];
|
||||
each(params: any, cb: (row: any) => void): void;
|
||||
each(cb: (row: any) => void): void;
|
||||
each(...params: any[]): void;
|
||||
pluck(toggleState?: boolean): this;
|
||||
bind(...params: any[]): this;
|
||||
safeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
|
||||
export class Transaction {
|
||||
database: Database;
|
||||
source: string;
|
||||
constructor(db: Database, sources: string[]);
|
||||
|
||||
run(...params: any[]): RunResult;
|
||||
bind(...params: any[]): this;
|
||||
safeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
|
||||
export interface DatabaseOptions {
|
||||
memory?: boolean;
|
||||
readonly?: boolean;
|
||||
fileMustExist?: boolean;
|
||||
}
|
||||
|
||||
export interface RegistrationOptions {
|
||||
name?: string;
|
||||
varargs?: boolean;
|
||||
deterministic?: boolean;
|
||||
safeIntegers?: boolean;
|
||||
}
|
||||
|
||||
export interface Database {
|
||||
memory: boolean;
|
||||
readonly: boolean;
|
||||
name: string;
|
||||
open: boolean;
|
||||
inTransaction: boolean;
|
||||
|
||||
prepare(source: string): Statement;
|
||||
transaction(sources: string[]): Transaction;
|
||||
exec(source: string): this;
|
||||
pragma(source: string, simplify?: boolean): any;
|
||||
checkpoint(databaseName?: string): this;
|
||||
register(cb: (...params: any[]) => any): this;
|
||||
register(options: RegistrationOptions, cb: (...params: any[]) => any): this;
|
||||
close(): this;
|
||||
defaultSafeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
|
||||
export class SqliteError implements Error {
|
||||
name: string;
|
||||
message: string;
|
||||
code: string;
|
||||
constructor(message: string, code: string);
|
||||
}
|
||||
|
||||
export interface DatabaseConstructor {
|
||||
new (filename: string, options?: DatabaseOptions): Database;
|
||||
(filename: string, options?: DatabaseOptions): Database;
|
||||
prototype: Database;
|
||||
|
||||
Integer: typeof Integer;
|
||||
SqliteError: typeof SqliteError;
|
||||
}
|
||||
Reference in New Issue
Block a user