@mikro-orm/better-sqlite 6.1.13-dev.3 → 6.1.13-dev.31

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,64 +7,11 @@ 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) {
14
+ /* istanbul ignore if */
68
15
  if (prop.runtimeType === 'Date') {
69
16
  return (0, sqlstring_sqlite_1.escape)(value, true, this.timezone).replace(/^'|\.\d{3}'$/g, '');
70
17
  }
@@ -80,17 +27,5 @@ class BetterSqlitePlatform extends knex_1.AbstractSqlPlatform {
80
27
  }
81
28
  return (0, sqlstring_sqlite_1.escape)(value, true, this.timezone);
82
29
  }
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
30
  }
96
31
  exports.BetterSqlitePlatform = BetterSqlitePlatform;
@@ -1,23 +1,3 @@
1
- import type { Connection, Dictionary } from '@mikro-orm/core';
2
- import { SchemaHelper, type AbstractSqlConnection, type IndexDef, type CheckDef } from '@mikro-orm/knex';
3
- export declare class BetterSqliteSchemaHelper extends SchemaHelper {
4
- disableForeignKeysSQL(): string;
5
- enableForeignKeysSQL(): string;
6
- supportsSchemaConstraints(): boolean;
7
- getListTablesSQL(): string;
8
- private parseTableDefinition;
9
- getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<any[]>;
10
- getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName: string, schemaName: string): Promise<Dictionary<string[]>>;
11
- getPrimaryKeys(connection: AbstractSqlConnection, indexes: IndexDef[], tableName: string, schemaName?: string): Promise<string[]>;
12
- getIndexes(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<IndexDef[]>;
13
- getChecks(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<CheckDef[]>;
14
- getForeignKeysSQL(tableName: string): string;
15
- mapForeignKeys(fks: any[], tableName: string): Dictionary;
16
- getManagementDbName(): string;
17
- getCreateDatabaseSQL(name: string): string;
18
- databaseExists(connection: Connection, name: string): Promise<boolean>;
19
- /**
20
- * Implicit indexes will be ignored when diffing
21
- */
22
- isImplicitIndex(name: string): boolean;
1
+ import { BaseSqliteSchemaHelper } from '@mikro-orm/knex';
2
+ export declare class BetterSqliteSchemaHelper extends BaseSqliteSchemaHelper {
23
3
  }
@@ -2,156 +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
- parseTableDefinition(sql, cols) {
20
- const columns = {};
21
- // extract all columns definitions
22
- let columnsDef = sql.replaceAll('\n', '').match(new RegExp(`create table [\`"']?.*?[\`"']? \\((.*)\\)`, 'i'))?.[1];
23
- /* istanbul ignore else */
24
- if (columnsDef) {
25
- for (let i = cols.length - 1; i >= 0; i--) {
26
- const col = cols[i];
27
- const re = ` *, *[\`"']?${col.name}[\`"']? (.*)`;
28
- const columnDef = columnsDef.match(new RegExp(re, 'i'));
29
- /* istanbul ignore else */
30
- if (columnDef) {
31
- columns[col.name] = { name: col.name, definition: columnDef[1] };
32
- columnsDef = columnsDef.substring(0, columnDef.index);
33
- }
34
- }
35
- }
36
- return columns;
37
- }
38
- async getColumns(connection, tableName, schemaName) {
39
- const columns = await connection.execute(`pragma table_xinfo('${tableName}')`);
40
- const sql = `select sql from sqlite_master where type = ? and name = ?`;
41
- const tableDefinition = await connection.execute(sql, ['table', tableName], 'get');
42
- const composite = columns.reduce((count, col) => count + (col.pk ? 1 : 0), 0) > 1;
43
- // there can be only one, so naive check like this should be enough
44
- const hasAutoincrement = tableDefinition.sql.toLowerCase().includes('autoincrement');
45
- const columnDefinitions = this.parseTableDefinition(tableDefinition.sql, columns);
46
- return columns.map(col => {
47
- const mappedType = connection.getPlatform().getMappedType(col.type);
48
- let generated;
49
- if (col.hidden > 1) {
50
- const storage = col.hidden === 2 ? 'virtual' : 'stored';
51
- const re = `(generated always)? as \\((.*)\\)( ${storage})?$`;
52
- const match = columnDefinitions[col.name].definition.match(re);
53
- if (match) {
54
- generated = `${match[2]} ${storage}`;
55
- }
56
- }
57
- return {
58
- name: col.name,
59
- type: col.type,
60
- default: col.dflt_value,
61
- nullable: !col.notnull,
62
- primary: !!col.pk,
63
- mappedType,
64
- unsigned: false,
65
- autoincrement: !composite && col.pk && this.platform.isNumericColumn(mappedType) && hasAutoincrement,
66
- generated,
67
- };
68
- });
69
- }
70
- async getEnumDefinitions(connection, checks, tableName, schemaName) {
71
- const sql = `select sql from sqlite_master where type = ? and name = ?`;
72
- const tableDefinition = await connection.execute(sql, ['table', tableName], 'get');
73
- const checkConstraints = [...tableDefinition.sql.match(/[`["'][^`\]"']+[`\]"'] text check \(.*?\)/gi) ?? []];
74
- return checkConstraints.reduce((o, item) => {
75
- // check constraints are defined as (note that last closing paren is missing):
76
- // `type` text check (`type` in ('local', 'global')
77
- const match = item.match(/[`["']([^`\]"']+)[`\]"'] text check \(.* \((.*)\)/i);
78
- /* istanbul ignore else */
79
- if (match) {
80
- o[match[1]] = match[2].split(',').map((item) => item.trim().match(/^\(?'(.*)'/)[1]);
81
- }
82
- return o;
83
- }, {});
84
- }
85
- async getPrimaryKeys(connection, indexes, tableName, schemaName) {
86
- const sql = `pragma table_info(\`${tableName}\`)`;
87
- const cols = await connection.execute(sql);
88
- return cols.filter(col => !!col.pk).map(col => col.name);
89
- }
90
- async getIndexes(connection, tableName, schemaName) {
91
- const sql = `pragma table_info(\`${tableName}\`)`;
92
- const cols = await connection.execute(sql);
93
- const indexes = await connection.execute(`pragma index_list(\`${tableName}\`)`);
94
- const ret = [];
95
- for (const col of cols.filter(c => c.pk)) {
96
- ret.push({
97
- columnNames: [col.name],
98
- keyName: 'primary',
99
- constraint: true,
100
- unique: true,
101
- primary: true,
102
- });
103
- }
104
- for (const index of indexes.filter(index => !this.isImplicitIndex(index.name))) {
105
- const res = await connection.execute(`pragma index_info(\`${index.name}\`)`);
106
- ret.push(...res.map(row => ({
107
- columnNames: [row.name],
108
- keyName: index.name,
109
- unique: !!index.unique,
110
- constraint: !!index.unique,
111
- primary: false,
112
- })));
113
- }
114
- return this.mapIndexes(ret);
115
- }
116
- async getChecks(connection, tableName, schemaName) {
117
- // Not supported at the moment.
118
- return [];
119
- }
120
- getForeignKeysSQL(tableName) {
121
- return `pragma foreign_key_list(\`${tableName}\`)`;
122
- }
123
- mapForeignKeys(fks, tableName) {
124
- return fks.reduce((ret, fk) => {
125
- ret[fk.from] = {
126
- constraintName: this.platform.getIndexName(tableName, [fk.from], 'foreign'),
127
- columnName: fk.from,
128
- columnNames: [fk.from],
129
- localTableName: tableName,
130
- referencedTableName: fk.table,
131
- referencedColumnName: fk.to,
132
- referencedColumnNames: [fk.to],
133
- updateRule: fk.on_update.toLowerCase(),
134
- deleteRule: fk.on_delete.toLowerCase(),
135
- };
136
- return ret;
137
- }, {});
138
- }
139
- getManagementDbName() {
140
- return '';
141
- }
142
- getCreateDatabaseSQL(name) {
143
- return '';
144
- }
145
- async databaseExists(connection, name) {
146
- const tables = await connection.execute(this.getListTablesSQL());
147
- return tables.length > 0;
148
- }
149
- /**
150
- * Implicit indexes will be ignored when diffing
151
- */
152
- isImplicitIndex(name) {
153
- // Ignore indexes with reserved names, e.g. autoindexes
154
- return name.startsWith('sqlite_');
155
- }
5
+ class BetterSqliteSchemaHelper extends knex_1.BaseSqliteSchemaHelper {
156
6
  }
157
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,27 @@ 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/mssql # for mssql
183
+ yarn add @mikro-orm/core @mikro-orm/sqlite # for sqlite
184
+ yarn add @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
185
+ yarn add @mikro-orm/core @mikro-orm/libsql # for libsql
183
186
  ```
184
187
 
185
188
  or
186
189
 
187
190
  ```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
191
+ npm i -s @mikro-orm/core @mikro-orm/mongodb # for mongo
192
+ npm i -s @mikro-orm/core @mikro-orm/mysql # for mysql/mariadb
193
+ npm i -s @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
194
+ npm i -s @mikro-orm/core @mikro-orm/postgresql # for postgresql
195
+ npm i -s @mikro-orm/core @mikro-orm/mssql # for mssql
196
+ npm i -s @mikro-orm/core @mikro-orm/sqlite # for sqlite
197
+ npm i -s @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
198
+ npm i -s @mikro-orm/core @mikro-orm/libsql # for libsql
193
199
  ```
194
200
 
195
201
  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.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.defineConfig = exports.MikroORM = void 0;
18
+ /* istanbul ignore file */
18
19
  __exportStar(require("@mikro-orm/knex"), exports);
19
20
  __exportStar(require("./BetterSqliteConnection"), exports);
20
21
  __exportStar(require("./BetterSqliteDriver"), exports);
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;
@@ -61,6 +65,7 @@ export const DateType = mod.DateType;
61
65
  export const DeadlockException = mod.DeadlockException;
62
66
  export const DecimalType = mod.DecimalType;
63
67
  export const DefaultLogger = mod.DefaultLogger;
68
+ export const DeferMode = mod.DeferMode;
64
69
  export const DoubleType = mod.DoubleType;
65
70
  export const DriverException = mod.DriverException;
66
71
  export const EagerProps = mod.EagerProps;
@@ -112,6 +117,7 @@ export const JoinType = mod.JoinType;
112
117
  export const JsonProperty = mod.JsonProperty;
113
118
  export const JsonType = mod.JsonType;
114
119
  export const Knex = mod.Knex;
120
+ export const LibSqlKnexDialect = mod.LibSqlKnexDialect;
115
121
  export const LoadStrategy = mod.LoadStrategy;
116
122
  export const LockMode = mod.LockMode;
117
123
  export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
@@ -127,6 +133,7 @@ export const MetadataValidator = mod.MetadataValidator;
127
133
  export const MikroORM = mod.MikroORM;
128
134
  export const MongoNamingStrategy = mod.MongoNamingStrategy;
129
135
  export const MonkeyPatchable = mod.MonkeyPatchable;
136
+ export const MsSqlKnexDialect = mod.MsSqlKnexDialect;
130
137
  export const NodeState = mod.NodeState;
131
138
  export const NonUniqueFieldNameException = mod.NonUniqueFieldNameException;
132
139
  export const NotFoundError = mod.NotFoundError;
@@ -145,6 +152,7 @@ export const OptionalProps = mod.OptionalProps;
145
152
  export const PlainObject = mod.PlainObject;
146
153
  export const Platform = mod.Platform;
147
154
  export const PopulateHint = mod.PopulateHint;
155
+ export const PopulatePath = mod.PopulatePath;
148
156
  export const PrimaryKey = mod.PrimaryKey;
149
157
  export const PrimaryKeyProp = mod.PrimaryKeyProp;
150
158
  export const Property = mod.Property;
@@ -177,6 +185,8 @@ export const SmallIntType = mod.SmallIntType;
177
185
  export const SqlEntityManager = mod.SqlEntityManager;
178
186
  export const SqlEntityRepository = mod.SqlEntityRepository;
179
187
  export const SqlSchemaGenerator = mod.SqlSchemaGenerator;
188
+ export const SqliteKnexDialect = mod.SqliteKnexDialect;
189
+ export const SqliteTableCompiler = mod.SqliteTableCompiler;
180
190
  export const StringType = mod.StringType;
181
191
  export const SyntaxErrorException = mod.SyntaxErrorException;
182
192
  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.3",
3
+ "version": "6.1.13-dev.31",
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,8 +58,8 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.1.13-dev.3",
62
- "better-sqlite3": "9.4.3",
61
+ "@mikro-orm/knex": "6.1.13-dev.31",
62
+ "better-sqlite3": "9.4.5",
63
63
  "fs-extra": "11.2.0",
64
64
  "sqlstring-sqlite": "0.1.1"
65
65
  },
@@ -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.3"
70
+ "@mikro-orm/core": "6.1.13-dev.31"
71
71
  }
72
72
  }