mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
[lovefield] Replace Object with object (#28757)
This is my first contribution, so I'm not sure if I missed something. I plan to make a more detailed edit in the future that replaces object with true generics, but it's not immediately obvious how to do that. Please fill in this template. - [x] Use a meaningful title for the pull request. Include the name of the package modified. - [x] Test the change in your own code. (Compile and run.) - [x] Add or edit tests to reflect the change. (Run with `npm test`.) - [x] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [x] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [x] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). Select one of these and delete the others: If changing an existing definition: - [x] Provide a URL to documentation or source code which provides context for the suggested changes: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes - [x] Increase the version number in the header if appropriate. - [x] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dtslint/dt.json" }`.
This commit is contained in:
Vendored
+10
-8
@@ -1,7 +1,9 @@
|
||||
// Type definitions for Lovefield 2.1
|
||||
// Project: http://google.github.io/lovefield/
|
||||
// Definitions by: freshp86 <https://github.com/freshp86>
|
||||
// zackzeno <https://github.com/zackzeno>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare namespace lf {
|
||||
enum Order { ASC, DESC }
|
||||
@@ -59,10 +61,10 @@ declare namespace lf {
|
||||
}
|
||||
|
||||
interface Transaction {
|
||||
attach(query: query.Builder): Promise<Object[]>;
|
||||
attach(query: query.Builder): Promise<object[]>;
|
||||
begin(scope: schema.Table[]): Promise<void>;
|
||||
commit(): Promise<void>;
|
||||
exec(queries: query.Builder[]): Promise<Object[][]>;
|
||||
exec(queries: query.Builder[]): Promise<object[][]>;
|
||||
rollback(): Promise<void>;
|
||||
stats(): TransactionStats;
|
||||
}
|
||||
@@ -73,9 +75,9 @@ declare namespace lf {
|
||||
close(): void;
|
||||
createTransaction(type?: TransactionType): Transaction;
|
||||
delete(): query.Delete;
|
||||
export(): Promise<Object>;
|
||||
export(): Promise<object>;
|
||||
getSchema(): schema.Database;
|
||||
import(data: Object): Promise<void>;
|
||||
import(data: object): Promise<void>;
|
||||
insertOrReplace(): query.Insert;
|
||||
insert(): query.Insert;
|
||||
observe(query: query.Select, callback: Function): void;
|
||||
@@ -87,7 +89,7 @@ declare namespace lf {
|
||||
namespace query {
|
||||
interface Builder {
|
||||
bind(...values: any[]): Builder;
|
||||
exec(): Promise<Object[]>;
|
||||
exec(): Promise<object[]>;
|
||||
explain(): string;
|
||||
toSql(): string;
|
||||
}
|
||||
@@ -131,9 +133,9 @@ declare namespace lf {
|
||||
renameTableColumn(
|
||||
tableName: string, oldColumnName: string,
|
||||
newColumnName: string): Promise<void>;
|
||||
createRow(payload: Object): Row;
|
||||
createRow(payload: object): Row;
|
||||
getVersion(): number;
|
||||
dump(): Object[];
|
||||
dump(): object[];
|
||||
}
|
||||
} // module raw
|
||||
|
||||
@@ -166,7 +168,7 @@ declare namespace lf {
|
||||
|
||||
interface ITable {
|
||||
as(name: string): Table;
|
||||
createRow(value: Object): Row;
|
||||
createRow(value: object): Row;
|
||||
getName(): string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import lf = require("lovefield");
|
||||
export interface IRow {
|
||||
id: number;
|
||||
description: string;
|
||||
deadline: Date;
|
||||
done: boolean;
|
||||
}
|
||||
function main(): void {
|
||||
const schemaBuilder: lf.schema.Builder = lf.schema.create('todo', 1);
|
||||
|
||||
@@ -28,11 +34,11 @@ function main(): void {
|
||||
});
|
||||
return db.insertOrReplace().into(itemSchema).values([row]).exec();
|
||||
}).then(() => {
|
||||
const column = itemSchema['done'];
|
||||
return todoDb.select().from(itemSchema).where(column.eq(false)).exec();
|
||||
const column = itemSchema.done;
|
||||
return todoDb.select().from(itemSchema).where(column.eq(false)).exec() as Promise<IRow[]>;
|
||||
}).then((results) => {
|
||||
results.forEach((row) => {
|
||||
document.body.textContent = `${(row as any).description} before ${(row as any).deadline}`;
|
||||
document.body.textContent = `${row.description} before ${row.deadline}`;
|
||||
});
|
||||
|
||||
return todoDb.delete().from(itemSchema);
|
||||
|
||||
Reference in New Issue
Block a user