@mikro-orm/better-sqlite 6.1.13-dev.25 → 6.1.13-dev.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,4 @@
1
- import { AbstractSqlConnection, type Knex } from '@mikro-orm/knex';
2
- export declare class BetterSqliteConnection extends AbstractSqlConnection {
1
+ import { BaseSqliteConnection } from '@mikro-orm/knex';
2
+ export declare class BetterSqliteConnection extends BaseSqliteConnection {
3
3
  createKnex(): void;
4
- connect(): Promise<void>;
5
- getDefaultClientUrl(): string;
6
- getClientUrl(): string;
7
- loadFile(path: string): Promise<void>;
8
- protected getKnexOptions(type: string): Knex.Config;
9
- protected transformRawResult<T>(res: any, method: 'all' | 'get' | 'run'): T;
10
- /**
11
- * monkey patch knex' BetterSqlite Dialect so it returns inserted id when doing raw insert query
12
- */
13
- private getPatchedDialect;
14
- private isRunQuery;
15
- private getCallMethod;
16
4
  }
@@ -1,166 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BetterSqliteConnection = void 0;
4
- const fs_extra_1 = require("fs-extra");
5
- const path_1 = require("path");
6
4
  const knex_1 = require("@mikro-orm/knex");
7
- const core_1 = require("@mikro-orm/core");
8
- class BetterSqliteConnection extends knex_1.AbstractSqlConnection {
5
+ class BetterSqliteConnection extends knex_1.BaseSqliteConnection {
9
6
  createKnex() {
10
- this.getPatchedDialect();
11
- this.client = this.createKnexClient('better-sqlite3');
7
+ this.client = this.createKnexClient(knex_1.BetterSqliteKnexDialect);
12
8
  this.connected = true;
13
9
  }
14
- async connect() {
15
- this.createKnex();
16
- await (0, fs_extra_1.ensureDir)((0, path_1.dirname)(this.config.get('dbName')));
17
- await this.client.raw('pragma foreign_keys = on');
18
- }
19
- getDefaultClientUrl() {
20
- return '';
21
- }
22
- getClientUrl() {
23
- return '';
24
- }
25
- async loadFile(path) {
26
- const conn = await this.client.client.acquireConnection();
27
- await conn.exec((await (0, fs_extra_1.readFile)(path)).toString());
28
- await this.client.client.releaseConnection(conn);
29
- }
30
- getKnexOptions(type) {
31
- return core_1.Utils.mergeConfig({
32
- client: type,
33
- connection: {
34
- filename: this.config.get('dbName'),
35
- },
36
- pool: this.config.get('pool'),
37
- useNullAsDefault: true,
38
- }, this.config.get('driverOptions'));
39
- }
40
- transformRawResult(res, method) {
41
- if (method === 'get') {
42
- return res[0];
43
- }
44
- if (method === 'all') {
45
- return res;
46
- }
47
- if (Array.isArray(res)) {
48
- return {
49
- insertId: res[res.length - 1]?.id ?? 0,
50
- affectedRows: res.length,
51
- row: res[0],
52
- rows: res,
53
- };
54
- }
55
- return {
56
- insertId: res.lastInsertRowid,
57
- affectedRows: res.changes,
58
- };
59
- }
60
- /**
61
- * monkey patch knex' BetterSqlite Dialect so it returns inserted id when doing raw insert query
62
- */
63
- getPatchedDialect() {
64
- const { Sqlite3Dialect, Sqlite3DialectTableCompiler } = knex_1.MonkeyPatchable;
65
- if (Sqlite3Dialect.prototype.__patched) {
66
- return Sqlite3Dialect;
67
- }
68
- const processResponse = Sqlite3Dialect.prototype.processResponse;
69
- Sqlite3Dialect.prototype.__patched = true;
70
- Sqlite3Dialect.prototype.processResponse = (obj, runner) => {
71
- if (obj.method === 'raw' && this.isRunQuery(obj.sql)) {
72
- return obj.response ?? obj.context;
73
- }
74
- return processResponse(obj, runner);
75
- };
76
- Sqlite3Dialect.prototype._query = (connection, obj) => {
77
- const callMethod = this.getCallMethod(obj);
78
- return new Promise((resolve, reject) => {
79
- /* istanbul ignore if */
80
- if (!connection?.[callMethod]) {
81
- return reject(new Error(`Error calling ${callMethod} on connection.`));
82
- }
83
- connection[callMethod](obj.sql, obj.bindings, function (err, response) {
84
- if (err) {
85
- return reject(err);
86
- }
87
- obj.response = response;
88
- obj.context = this;
89
- return resolve(obj);
90
- });
91
- });
92
- };
93
- /* istanbul ignore next */
94
- Sqlite3DialectTableCompiler.prototype.foreign = function (foreignInfo) {
95
- foreignInfo.column = this.formatter.columnize(foreignInfo.column);
96
- foreignInfo.column = Array.isArray(foreignInfo.column)
97
- ? foreignInfo.column
98
- : [foreignInfo.column];
99
- foreignInfo.column = foreignInfo.column.map((column) => this.client.customWrapIdentifier(column, (a) => a));
100
- foreignInfo.inTable = this.client.customWrapIdentifier(foreignInfo.inTable, (a) => a);
101
- foreignInfo.references = Array.isArray(foreignInfo.references)
102
- ? foreignInfo.references
103
- : [foreignInfo.references];
104
- foreignInfo.references = foreignInfo.references.map((column) => this.client.customWrapIdentifier(column, (a) => a));
105
- // quoted versions
106
- const column = this.formatter.columnize(foreignInfo.column);
107
- const inTable = this.formatter.columnize(foreignInfo.inTable);
108
- const references = this.formatter.columnize(foreignInfo.references);
109
- const keyName = this.formatter.columnize(foreignInfo.keyName);
110
- const addColumnQuery = this.sequence.find((query) => query.sql.includes(`add column ${column[0]}`));
111
- // no need for temp tables if we just add a column
112
- if (addColumnQuery) {
113
- const onUpdate = foreignInfo.onUpdate ? ` on update ${foreignInfo.onUpdate}` : '';
114
- const deleteRule = foreignInfo.deleteRule ? ` on delete ${foreignInfo.deleteRule}` : '';
115
- addColumnQuery.sql += ` constraint ${keyName} references ${inTable} (${references})${onUpdate}${deleteRule}`;
116
- return;
117
- }
118
- // eslint-disable-next-line @typescript-eslint/no-this-alias
119
- const compiler = this;
120
- if (this.method !== 'create' && this.method !== 'createIfNot') {
121
- this.pushQuery({
122
- sql: `PRAGMA table_info(${this.tableName()})`,
123
- statementsProducer(pragma, connection) {
124
- return compiler.client
125
- .ddl(compiler, pragma, connection)
126
- .foreign(foreignInfo);
127
- },
128
- });
129
- }
130
- };
131
- return Sqlite3Dialect;
132
- }
133
- isRunQuery(query) {
134
- query = query.trim().toLowerCase();
135
- if ((query.startsWith('insert into') || query.startsWith('update ')) && query.includes(' returning ')) {
136
- return false;
137
- }
138
- return query.startsWith('insert into') ||
139
- query.startsWith('update') ||
140
- query.startsWith('delete') ||
141
- query.startsWith('truncate');
142
- }
143
- getCallMethod(obj) {
144
- if (obj.method === 'raw') {
145
- const query = obj.sql.trim().toLowerCase();
146
- if ((query.startsWith('insert into') || query.startsWith('update ')) && query.includes(' returning ')) {
147
- return 'all';
148
- }
149
- if (this.isRunQuery(query)) {
150
- return 'run';
151
- }
152
- }
153
- /* istanbul ignore next */
154
- switch (obj.method) {
155
- case 'insert':
156
- case 'update':
157
- return obj.returning ? 'all' : 'run';
158
- case 'counter':
159
- case 'del':
160
- return 'run';
161
- default:
162
- return 'all';
163
- }
164
- }
165
10
  }
166
11
  exports.BetterSqliteConnection = BetterSqliteConnection;
@@ -1,55 +1,10 @@
1
1
  import { type EntityProperty } from '@mikro-orm/core';
2
- import { AbstractSqlPlatform } from '@mikro-orm/knex';
2
+ import { BaseSqlitePlatform } from '@mikro-orm/knex';
3
3
  import { BetterSqliteSchemaHelper } from './BetterSqliteSchemaHelper';
4
4
  import { BetterSqliteExceptionConverter } from './BetterSqliteExceptionConverter';
5
- export declare class BetterSqlitePlatform extends AbstractSqlPlatform {
5
+ export declare class BetterSqlitePlatform extends BaseSqlitePlatform {
6
6
  protected readonly schemaHelper: BetterSqliteSchemaHelper;
7
7
  protected readonly exceptionConverter: BetterSqliteExceptionConverter;
8
- usesDefaultKeyword(): boolean;
9
- usesReturningStatement(): boolean;
10
- getCurrentTimestampSQL(length: number): string;
11
- getDateTimeTypeDeclarationSQL(column: {
12
- length: number;
13
- }): string;
14
- getEnumTypeDeclarationSQL(column: {
15
- items?: unknown[];
16
- fieldNames: string[];
17
- length?: number;
18
- unsigned?: boolean;
19
- autoincrement?: boolean;
20
- }): string;
21
- getTinyIntTypeDeclarationSQL(column: {
22
- length?: number;
23
- unsigned?: boolean;
24
- autoincrement?: boolean;
25
- }): string;
26
- getSmallIntTypeDeclarationSQL(column: {
27
- length?: number;
28
- unsigned?: boolean;
29
- autoincrement?: boolean;
30
- }): string;
31
- getIntegerTypeDeclarationSQL(column: {
32
- length?: number;
33
- unsigned?: boolean;
34
- autoincrement?: boolean;
35
- }): string;
36
- getFloatDeclarationSQL(): string;
37
- getBooleanTypeDeclarationSQL(): string;
38
- getVarcharTypeDeclarationSQL(column: {
39
- length?: number;
40
- }): string;
41
- convertsJsonAutomatically(): boolean;
42
- allowsComparingTuples(): boolean;
43
- /**
44
- * This is used to narrow the value of Date properties as they will be stored as timestamps in sqlite.
45
- * We use this method to convert Dates to timestamps when computing the changeset, so we have the right
46
- * data type in the payload as well as in original entity data. Without that, we would end up with diffs
47
- * including all Date properties, as we would be comparing Date object with timestamp.
48
- */
49
- processDateProperty(value: unknown): string | number | Date;
50
8
  quoteVersionValue(value: Date | number, prop: EntityProperty): Date | string | number;
51
9
  quoteValue(value: any): string;
52
- getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
53
- getDefaultPrimaryName(tableName: string, columns: string[]): string;
54
- supportsDownMigrations(): boolean;
55
10
  }
@@ -7,63 +7,9 @@ const core_1 = require("@mikro-orm/core");
7
7
  const knex_1 = require("@mikro-orm/knex");
8
8
  const BetterSqliteSchemaHelper_1 = require("./BetterSqliteSchemaHelper");
9
9
  const BetterSqliteExceptionConverter_1 = require("./BetterSqliteExceptionConverter");
10
- class BetterSqlitePlatform extends knex_1.AbstractSqlPlatform {
10
+ class BetterSqlitePlatform extends knex_1.BaseSqlitePlatform {
11
11
  schemaHelper = new BetterSqliteSchemaHelper_1.BetterSqliteSchemaHelper(this);
12
12
  exceptionConverter = new BetterSqliteExceptionConverter_1.BetterSqliteExceptionConverter();
13
- usesDefaultKeyword() {
14
- return false;
15
- }
16
- usesReturningStatement() {
17
- return true;
18
- }
19
- getCurrentTimestampSQL(length) {
20
- return super.getCurrentTimestampSQL(0);
21
- }
22
- getDateTimeTypeDeclarationSQL(column) {
23
- return 'datetime';
24
- }
25
- getEnumTypeDeclarationSQL(column) {
26
- if (column.items?.every(item => core_1.Utils.isString(item))) {
27
- return 'text';
28
- }
29
- return this.getTinyIntTypeDeclarationSQL(column);
30
- }
31
- getTinyIntTypeDeclarationSQL(column) {
32
- return this.getIntegerTypeDeclarationSQL(column);
33
- }
34
- getSmallIntTypeDeclarationSQL(column) {
35
- return this.getIntegerTypeDeclarationSQL(column);
36
- }
37
- getIntegerTypeDeclarationSQL(column) {
38
- return 'integer';
39
- }
40
- getFloatDeclarationSQL() {
41
- return 'real';
42
- }
43
- getBooleanTypeDeclarationSQL() {
44
- return 'integer';
45
- }
46
- getVarcharTypeDeclarationSQL(column) {
47
- return 'text';
48
- }
49
- convertsJsonAutomatically() {
50
- return false;
51
- }
52
- allowsComparingTuples() {
53
- return false;
54
- }
55
- /**
56
- * This is used to narrow the value of Date properties as they will be stored as timestamps in sqlite.
57
- * We use this method to convert Dates to timestamps when computing the changeset, so we have the right
58
- * data type in the payload as well as in original entity data. Without that, we would end up with diffs
59
- * including all Date properties, as we would be comparing Date object with timestamp.
60
- */
61
- processDateProperty(value) {
62
- if (value instanceof Date) {
63
- return +value;
64
- }
65
- return value;
66
- }
67
13
  quoteVersionValue(value, prop) {
68
14
  if (prop.runtimeType === 'Date') {
69
15
  return (0, sqlstring_sqlite_1.escape)(value, true, this.timezone).replace(/^'|\.\d{3}'$/g, '');
@@ -80,17 +26,5 @@ class BetterSqlitePlatform extends knex_1.AbstractSqlPlatform {
80
26
  }
81
27
  return (0, sqlstring_sqlite_1.escape)(value, true, this.timezone);
82
28
  }
83
- getIndexName(tableName, columns, type) {
84
- if (type === 'primary') {
85
- return this.getDefaultPrimaryName(tableName, columns);
86
- }
87
- return super.getIndexName(tableName, columns, type);
88
- }
89
- getDefaultPrimaryName(tableName, columns) {
90
- return 'primary';
91
- }
92
- supportsDownMigrations() {
93
- return false;
94
- }
95
29
  }
96
30
  exports.BetterSqlitePlatform = BetterSqlitePlatform;
@@ -1,25 +1,3 @@
1
- import type { Connection, Dictionary } from '@mikro-orm/core';
2
- import { SchemaHelper, type AbstractSqlConnection, type IndexDef, type CheckDef, type Column } from '@mikro-orm/knex';
3
- export declare class BetterSqliteSchemaHelper extends SchemaHelper {
4
- disableForeignKeysSQL(): string;
5
- enableForeignKeysSQL(): string;
6
- supportsSchemaConstraints(): boolean;
7
- getListTablesSQL(): string;
8
- getDropDatabaseSQL(name: string): string;
9
- getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string;
10
- private parseTableDefinition;
11
- getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<any[]>;
12
- getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName: string, schemaName: string): Promise<Dictionary<string[]>>;
13
- getPrimaryKeys(connection: AbstractSqlConnection, indexes: IndexDef[], tableName: string, schemaName?: string): Promise<string[]>;
14
- getIndexes(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<IndexDef[]>;
15
- getChecks(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<CheckDef[]>;
16
- getForeignKeysSQL(tableName: string): string;
17
- mapForeignKeys(fks: any[], tableName: string): Dictionary;
18
- getManagementDbName(): string;
19
- getCreateDatabaseSQL(name: string): string;
20
- databaseExists(connection: Connection, name: string): Promise<boolean>;
21
- /**
22
- * Implicit indexes will be ignored when diffing
23
- */
24
- isImplicitIndex(name: string): boolean;
1
+ import { BaseSqliteSchemaHelper } from '@mikro-orm/knex';
2
+ export declare class BetterSqliteSchemaHelper extends BaseSqliteSchemaHelper {
25
3
  }
@@ -2,168 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BetterSqliteSchemaHelper = void 0;
4
4
  const knex_1 = require("@mikro-orm/knex");
5
- class BetterSqliteSchemaHelper extends knex_1.SchemaHelper {
6
- disableForeignKeysSQL() {
7
- return 'pragma foreign_keys = off;';
8
- }
9
- enableForeignKeysSQL() {
10
- return 'pragma foreign_keys = on;';
11
- }
12
- supportsSchemaConstraints() {
13
- return false;
14
- }
15
- getListTablesSQL() {
16
- return `select name as table_name from sqlite_master where type = 'table' and name != 'sqlite_sequence' and name != 'geometry_columns' and name != 'spatial_ref_sys' `
17
- + `union all select name as table_name from sqlite_temp_master where type = 'table' order by name`;
18
- }
19
- getDropDatabaseSQL(name) {
20
- if (name === ':memory:') {
21
- return '';
22
- }
23
- return `drop database if exists ${this.platform.quoteIdentifier(name)}`;
24
- }
25
- getDropColumnsSQL(tableName, columns, schemaName) {
26
- const name = this.platform.quoteIdentifier((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
27
- return columns.map(column => {
28
- return `alter table ${name} drop column ${this.platform.quoteIdentifier(column.name)}`;
29
- }).join(';\n');
30
- }
31
- parseTableDefinition(sql, cols) {
32
- const columns = {};
33
- // extract all columns definitions
34
- let columnsDef = sql.replaceAll('\n', '').match(new RegExp(`create table [\`"']?.*?[\`"']? \\((.*)\\)`, 'i'))?.[1];
35
- /* istanbul ignore else */
36
- if (columnsDef) {
37
- for (let i = cols.length - 1; i >= 0; i--) {
38
- const col = cols[i];
39
- const re = ` *, *[\`"']?${col.name}[\`"']? (.*)`;
40
- const columnDef = columnsDef.match(new RegExp(re, 'i'));
41
- /* istanbul ignore else */
42
- if (columnDef) {
43
- columns[col.name] = { name: col.name, definition: columnDef[1] };
44
- columnsDef = columnsDef.substring(0, columnDef.index);
45
- }
46
- }
47
- }
48
- return columns;
49
- }
50
- async getColumns(connection, tableName, schemaName) {
51
- const columns = await connection.execute(`pragma table_xinfo('${tableName}')`);
52
- const sql = `select sql from sqlite_master where type = ? and name = ?`;
53
- const tableDefinition = await connection.execute(sql, ['table', tableName], 'get');
54
- const composite = columns.reduce((count, col) => count + (col.pk ? 1 : 0), 0) > 1;
55
- // there can be only one, so naive check like this should be enough
56
- const hasAutoincrement = tableDefinition.sql.toLowerCase().includes('autoincrement');
57
- const columnDefinitions = this.parseTableDefinition(tableDefinition.sql, columns);
58
- return columns.map(col => {
59
- const mappedType = connection.getPlatform().getMappedType(col.type);
60
- let generated;
61
- if (col.hidden > 1) {
62
- const storage = col.hidden === 2 ? 'virtual' : 'stored';
63
- const re = `(generated always)? as \\((.*)\\)( ${storage})?$`;
64
- const match = columnDefinitions[col.name].definition.match(re);
65
- if (match) {
66
- generated = `${match[2]} ${storage}`;
67
- }
68
- }
69
- return {
70
- name: col.name,
71
- type: col.type,
72
- default: col.dflt_value,
73
- nullable: !col.notnull,
74
- primary: !!col.pk,
75
- mappedType,
76
- unsigned: false,
77
- autoincrement: !composite && col.pk && this.platform.isNumericColumn(mappedType) && hasAutoincrement,
78
- generated,
79
- };
80
- });
81
- }
82
- async getEnumDefinitions(connection, checks, tableName, schemaName) {
83
- const sql = `select sql from sqlite_master where type = ? and name = ?`;
84
- const tableDefinition = await connection.execute(sql, ['table', tableName], 'get');
85
- const checkConstraints = [...tableDefinition.sql.match(/[`["'][^`\]"']+[`\]"'] text check \(.*?\)/gi) ?? []];
86
- return checkConstraints.reduce((o, item) => {
87
- // check constraints are defined as (note that last closing paren is missing):
88
- // `type` text check (`type` in ('local', 'global')
89
- const match = item.match(/[`["']([^`\]"']+)[`\]"'] text check \(.* \((.*)\)/i);
90
- /* istanbul ignore else */
91
- if (match) {
92
- o[match[1]] = match[2].split(',').map((item) => item.trim().match(/^\(?'(.*)'/)[1]);
93
- }
94
- return o;
95
- }, {});
96
- }
97
- async getPrimaryKeys(connection, indexes, tableName, schemaName) {
98
- const sql = `pragma table_info(\`${tableName}\`)`;
99
- const cols = await connection.execute(sql);
100
- return cols.filter(col => !!col.pk).map(col => col.name);
101
- }
102
- async getIndexes(connection, tableName, schemaName) {
103
- const sql = `pragma table_info(\`${tableName}\`)`;
104
- const cols = await connection.execute(sql);
105
- const indexes = await connection.execute(`pragma index_list(\`${tableName}\`)`);
106
- const ret = [];
107
- for (const col of cols.filter(c => c.pk)) {
108
- ret.push({
109
- columnNames: [col.name],
110
- keyName: 'primary',
111
- constraint: true,
112
- unique: true,
113
- primary: true,
114
- });
115
- }
116
- for (const index of indexes.filter(index => !this.isImplicitIndex(index.name))) {
117
- const res = await connection.execute(`pragma index_info(\`${index.name}\`)`);
118
- ret.push(...res.map(row => ({
119
- columnNames: [row.name],
120
- keyName: index.name,
121
- unique: !!index.unique,
122
- constraint: !!index.unique,
123
- primary: false,
124
- })));
125
- }
126
- return this.mapIndexes(ret);
127
- }
128
- async getChecks(connection, tableName, schemaName) {
129
- // Not supported at the moment.
130
- return [];
131
- }
132
- getForeignKeysSQL(tableName) {
133
- return `pragma foreign_key_list(\`${tableName}\`)`;
134
- }
135
- mapForeignKeys(fks, tableName) {
136
- return fks.reduce((ret, fk) => {
137
- ret[fk.from] = {
138
- constraintName: this.platform.getIndexName(tableName, [fk.from], 'foreign'),
139
- columnName: fk.from,
140
- columnNames: [fk.from],
141
- localTableName: tableName,
142
- referencedTableName: fk.table,
143
- referencedColumnName: fk.to,
144
- referencedColumnNames: [fk.to],
145
- updateRule: fk.on_update.toLowerCase(),
146
- deleteRule: fk.on_delete.toLowerCase(),
147
- };
148
- return ret;
149
- }, {});
150
- }
151
- getManagementDbName() {
152
- return '';
153
- }
154
- getCreateDatabaseSQL(name) {
155
- return '';
156
- }
157
- async databaseExists(connection, name) {
158
- const tables = await connection.execute(this.getListTablesSQL());
159
- return tables.length > 0;
160
- }
161
- /**
162
- * Implicit indexes will be ignored when diffing
163
- */
164
- isImplicitIndex(name) {
165
- // Ignore indexes with reserved names, e.g. autoindexes
166
- return name.startsWith('sqlite_');
167
- }
5
+ class BetterSqliteSchemaHelper extends knex_1.BaseSqliteSchemaHelper {
168
6
  }
169
7
  exports.BetterSqliteSchemaHelper = BetterSqliteSchemaHelper;
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <a href="https://mikro-orm.io"><img src="https://raw.githubusercontent.com/mikro-orm/mikro-orm/master/docs/static/img/logo-readme.svg?sanitize=true" alt="MikroORM" /></a>
3
3
  </h1>
4
4
 
5
- TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-orm.io/docs/unit-of-work/) and [Identity Map](https://mikro-orm.io/docs/identity-map/) patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
5
+ TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-orm.io/docs/unit-of-work/) and [Identity Map](https://mikro-orm.io/docs/identity-map/) patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite (including libSQL) databases.
6
6
 
7
7
  > Heavily inspired by [Doctrine](https://www.doctrine-project.org/) and [Hibernate](https://hibernate.org/).
8
8
 
@@ -175,21 +175,25 @@ First install the module via `yarn` or `npm` and do not forget to install the da
175
175
  > Since v4, you should install the driver package, but not the db connector itself, e.g. install `@mikro-orm/sqlite`, but not `sqlite3` as that is already included in the driver package.
176
176
 
177
177
  ```sh
178
- yarn add @mikro-orm/core @mikro-orm/mongodb # for mongo
179
- yarn add @mikro-orm/core @mikro-orm/mysql # for mysql/mariadb
180
- yarn add @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
181
- yarn add @mikro-orm/core @mikro-orm/postgresql # for postgresql
182
- yarn add @mikro-orm/core @mikro-orm/sqlite # for sqlite
178
+ yarn add @mikro-orm/core @mikro-orm/mongodb # for mongo
179
+ yarn add @mikro-orm/core @mikro-orm/mysql # for mysql/mariadb
180
+ yarn add @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
181
+ yarn add @mikro-orm/core @mikro-orm/postgresql # for postgresql
182
+ yarn add @mikro-orm/core @mikro-orm/sqlite # for sqlite
183
+ yarn add @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
184
+ yarn add @mikro-orm/core @mikro-orm/libsql # for libsql
183
185
  ```
184
186
 
185
187
  or
186
188
 
187
189
  ```sh
188
- npm i -s @mikro-orm/core @mikro-orm/mongodb # for mongo
189
- npm i -s @mikro-orm/core @mikro-orm/mysql # for mysql/mariadb
190
- npm i -s @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
191
- npm i -s @mikro-orm/core @mikro-orm/postgresql # for postgresql
192
- npm i -s @mikro-orm/core @mikro-orm/sqlite # for sqlite
190
+ npm i -s @mikro-orm/core @mikro-orm/mongodb # for mongo
191
+ npm i -s @mikro-orm/core @mikro-orm/mysql # for mysql/mariadb
192
+ npm i -s @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
193
+ npm i -s @mikro-orm/core @mikro-orm/postgresql # for postgresql
194
+ npm i -s @mikro-orm/core @mikro-orm/sqlite # for sqlite
195
+ npm i -s @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
196
+ npm i -s @mikro-orm/core @mikro-orm/libsql # for libsql
193
197
  ```
194
198
 
195
199
  Next, if you want to use decorators for your entity definition, you will need to enable support for [decorators](https://www.typescriptlang.org/docs/handbook/decorators.html) as well as `esModuleInterop` in `tsconfig.json` via:
package/index.mjs CHANGED
@@ -17,6 +17,9 @@ export const ArrayCollection = mod.ArrayCollection;
17
17
  export const ArrayCriteriaNode = mod.ArrayCriteriaNode;
18
18
  export const ArrayType = mod.ArrayType;
19
19
  export const BaseEntity = mod.BaseEntity;
20
+ export const BaseSqliteConnection = mod.BaseSqliteConnection;
21
+ export const BaseSqlitePlatform = mod.BaseSqlitePlatform;
22
+ export const BaseSqliteSchemaHelper = mod.BaseSqliteSchemaHelper;
20
23
  export const BeforeCreate = mod.BeforeCreate;
21
24
  export const BeforeDelete = mod.BeforeDelete;
22
25
  export const BeforeUpdate = mod.BeforeUpdate;
@@ -24,6 +27,7 @@ export const BeforeUpsert = mod.BeforeUpsert;
24
27
  export const BetterSqliteConnection = mod.BetterSqliteConnection;
25
28
  export const BetterSqliteDriver = mod.BetterSqliteDriver;
26
29
  export const BetterSqliteExceptionConverter = mod.BetterSqliteExceptionConverter;
30
+ export const BetterSqliteKnexDialect = mod.BetterSqliteKnexDialect;
27
31
  export const BetterSqlitePlatform = mod.BetterSqlitePlatform;
28
32
  export const BetterSqliteSchemaHelper = mod.BetterSqliteSchemaHelper;
29
33
  export const BigIntType = mod.BigIntType;
@@ -113,6 +117,7 @@ export const JoinType = mod.JoinType;
113
117
  export const JsonProperty = mod.JsonProperty;
114
118
  export const JsonType = mod.JsonType;
115
119
  export const Knex = mod.Knex;
120
+ export const LibSqlKnexDialect = mod.LibSqlKnexDialect;
116
121
  export const LoadStrategy = mod.LoadStrategy;
117
122
  export const LockMode = mod.LockMode;
118
123
  export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
@@ -178,6 +183,8 @@ export const SmallIntType = mod.SmallIntType;
178
183
  export const SqlEntityManager = mod.SqlEntityManager;
179
184
  export const SqlEntityRepository = mod.SqlEntityRepository;
180
185
  export const SqlSchemaGenerator = mod.SqlSchemaGenerator;
186
+ export const SqliteKnexDialect = mod.SqliteKnexDialect;
187
+ export const SqliteTableCompiler = mod.SqliteTableCompiler;
181
188
  export const StringType = mod.StringType;
182
189
  export const SyntaxErrorException = mod.SyntaxErrorException;
183
190
  export const TableExistsException = mod.TableExistsException;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/better-sqlite",
3
- "version": "6.1.13-dev.25",
3
+ "version": "6.1.13-dev.27",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.1.13-dev.25",
61
+ "@mikro-orm/knex": "6.1.13-dev.27",
62
62
  "better-sqlite3": "9.4.5",
63
63
  "fs-extra": "11.2.0",
64
64
  "sqlstring-sqlite": "0.1.1"
@@ -67,6 +67,6 @@
67
67
  "@mikro-orm/core": "^6.1.12"
68
68
  },
69
69
  "peerDependencies": {
70
- "@mikro-orm/core": "6.1.13-dev.25"
70
+ "@mikro-orm/core": "6.1.13-dev.27"
71
71
  }
72
72
  }