bun-types
Advanced tools
Comparing version 1.1.14-canary.20240616T140455 to 1.1.14-canary.20240617T140525
{ | ||
"version": "1.1.14-canary.20240616T140455", | ||
"version": "1.1.14-canary.20240617T140525", | ||
"name": "bun-types", | ||
@@ -4,0 +4,0 @@ "license": "MIT", |
@@ -85,2 +85,36 @@ /** | ||
readwrite?: boolean; | ||
/** | ||
* When set to `true`, integers are returned as `bigint` types. | ||
* | ||
* When set to `false`, integers are returned as `number` types and truncated to 52 bits. | ||
* | ||
* @default false | ||
* @since v1.1.14 | ||
*/ | ||
safeInteger?: boolean; | ||
/** | ||
* When set to `false` or `undefined`: | ||
* - Queries missing bound parameters will NOT throw an error | ||
* - Bound named parameters in JavaScript need to exactly match the SQL query. | ||
* | ||
* @example | ||
* ```ts | ||
* const db = new Database(":memory:", { strict: false }); | ||
* db.run("INSERT INTO foo (name) VALUES ($name)", { $name: "foo" }); | ||
* ``` | ||
* | ||
* When set to `true`: | ||
* - Queries missing bound parameters will throw an error | ||
* - Bound named parameters in JavaScript no longer need to be `$`, `:`, or `@`. The SQL query will remain prefixed. | ||
* | ||
* @example | ||
* ```ts | ||
* const db = new Database(":memory:", { strict: true }); | ||
* db.run("INSERT INTO foo (name) VALUES ($name)", { name: "foo" }); | ||
* ``` | ||
* @since v1.1.14 | ||
*/ | ||
strict?: boolean; | ||
}, | ||
@@ -172,3 +206,3 @@ ); | ||
...bindings: ParamsType[] | ||
): void; | ||
): Changes; | ||
/** | ||
@@ -180,3 +214,3 @@ This is an alias of {@link Database.prototype.run} | ||
...bindings: ParamsType[] | ||
): void; | ||
): Changes; | ||
@@ -601,3 +635,3 @@ /** | ||
*/ | ||
run(...params: ParamsType): void; | ||
run(...params: ParamsType): Changes; | ||
@@ -710,2 +744,40 @@ /** | ||
/** | ||
* | ||
* Make {@link get} and {@link all} return an instance of the provided | ||
* `Class` instead of the default `Object`. | ||
* | ||
* @param Class A class to use | ||
* @returns The same statement instance, modified to return an instance of `Class` | ||
* | ||
* This lets you attach methods, getters, and setters to the returned | ||
* objects. | ||
* | ||
* For performance reasons, constructors for classes are not called, which means | ||
* initializers will not be called and private fields will not be | ||
* accessible. | ||
* | ||
* @example | ||
* | ||
* ## Custom class | ||
* ```ts | ||
* class User { | ||
* rawBirthdate: string; | ||
* get birthdate() { | ||
* return new Date(this.rawBirthdate); | ||
* } | ||
* } | ||
* | ||
* const db = new Database(":memory:"); | ||
* db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, rawBirthdate TEXT)"); | ||
* db.run("INSERT INTO users (rawBirthdate) VALUES ('1995-12-19')"); | ||
* const query = db.query("SELECT * FROM users"); | ||
* query.as(User); | ||
* const user = query.get(); | ||
* console.log(user.birthdate); | ||
* // => Date(1995, 11, 19) | ||
* ``` | ||
*/ | ||
as<T = unknown>(Class: new (...args: any[]) => T): Statement<T, ParamsType>; | ||
/** | ||
* Native object representing the underlying `sqlite3_stmt` | ||
@@ -1073,2 +1145,19 @@ * | ||
} | ||
/** | ||
* An object representing the changes made to the database since the last `run` or `exec` call. | ||
* | ||
* @since Bun v1.1.14 | ||
*/ | ||
interface Changes { | ||
/** | ||
* The number of rows changed by the last `run` or `exec` call. | ||
*/ | ||
changes: number; | ||
/** | ||
* If `safeIntegers` is `true`, this is a `bigint`. Otherwise, it is a `number`. | ||
*/ | ||
lastInsertRowid: number | bigint; | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
368971
11931