mirror of
https://github.com/denoland/deno.git
synced 2025-09-21 18:10:02 +00:00

Related:
d1eabcb044
Related: https://github.com/nodejs/node/pull/59405
Related: https://github.com/better-auth/better-auth/pull/3869
Related: https://github.com/oven-sh/bun/pull/22109
Nowadays, there are tons of database packages, like sqlite3, sqlite,
better-sqlite, bun:sqlite... Checking the difference from them is pretty
hard.
instanceof is not good, since the developer will still need to import
the module, which is costly.
I think we should provide a symbol to distinguish different SQLite
classes, at least nodejs could make the first step.
---------
Signed-off-by: Alex Yang <himself65@outlook.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
37 lines
821 B
TypeScript
37 lines
821 B
TypeScript
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
|
|
import { primordials } from "ext:core/mod.js";
|
|
import { DatabaseSync, StatementSync } from "ext:core/ops";
|
|
|
|
const {
|
|
ObjectDefineProperty,
|
|
SymbolFor,
|
|
} = primordials;
|
|
|
|
export const constants = {
|
|
SQLITE_CHANGESET_OMIT: 0,
|
|
SQLITE_CHANGESET_REPLACE: 1,
|
|
SQLITE_CHANGESET_ABORT: 2,
|
|
|
|
SQLITE_CHANGESET_DATA: 1,
|
|
SQLITE_CHANGESET_NOTFOUND: 2,
|
|
SQLITE_CHANGESET_CONFLICT: 3,
|
|
SQLITE_CHANGESET_CONSTRAINT: 4,
|
|
SQLITE_CHANGESET_FOREIGN_KEY: 5,
|
|
};
|
|
|
|
const sqliteTypeSymbol = SymbolFor("sqlite-type");
|
|
ObjectDefineProperty(DatabaseSync.prototype, sqliteTypeSymbol, {
|
|
__proto__: null,
|
|
value: "node:sqlite",
|
|
enumerable: false,
|
|
configurable: true,
|
|
});
|
|
|
|
export { DatabaseSync, StatementSync };
|
|
|
|
export default {
|
|
constants,
|
|
DatabaseSync,
|
|
StatementSync,
|
|
};
|