@yandjin-mikro-orm/better-sqlite 6.1.4-rc-sti-changes-1
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.
- package/BetterSqliteConnection.d.ts +16 -0
- package/BetterSqliteConnection.js +172 -0
- package/BetterSqliteDriver.d.ts +6 -0
- package/BetterSqliteDriver.js +15 -0
- package/BetterSqliteExceptionConverter.d.ts +9 -0
- package/BetterSqliteExceptionConverter.js +56 -0
- package/BetterSqliteMikroORM.d.ts +19 -0
- package/BetterSqliteMikroORM.js +29 -0
- package/BetterSqlitePlatform.d.ts +55 -0
- package/BetterSqlitePlatform.js +96 -0
- package/BetterSqliteSchemaHelper.d.ts +23 -0
- package/BetterSqliteSchemaHelper.js +168 -0
- package/LICENSE +21 -0
- package/README.md +383 -0
- package/index.d.ts +7 -0
- package/index.js +26 -0
- package/index.mjs +220 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Martin Adámek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
<h1 align="center">
|
|
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
|
+
</h1>
|
|
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.
|
|
6
|
+
|
|
7
|
+
> Heavily inspired by [Doctrine](https://www.doctrine-project.org/) and [Hibernate](https://hibernate.org/).
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/@mikro-orm/core)
|
|
10
|
+
[](https://www.npmjs.com/package/@mikro-orm/core)
|
|
11
|
+
[](https://join.slack.com/t/mikroorm/shared_invite/enQtNTM1ODYzMzM4MDk3LWM4ZDExMjU5ZDhmNjA2MmM3MWMwZmExNjhhNDdiYTMwNWM0MGY5ZTE3ZjkyZTMzOWExNDgyYmMzNDE1NDI5NjA)
|
|
12
|
+
[](https://www.npmjs.com/package/@mikro-orm/core)
|
|
13
|
+
[](https://coveralls.io/r/mikro-orm/mikro-orm?branch=master)
|
|
14
|
+
[](https://codeclimate.com/github/mikro-orm/mikro-orm/maintainability)
|
|
15
|
+
[](https://github.com/mikro-orm/mikro-orm/actions?workflow=tests)
|
|
16
|
+
|
|
17
|
+
## 🤔 Unit of What?
|
|
18
|
+
|
|
19
|
+
You might be asking: _What the hell is Unit of Work and why should I care about it?_
|
|
20
|
+
|
|
21
|
+
> Unit of Work maintains a list of objects (_entities_) affected by a business transaction
|
|
22
|
+
> and coordinates the writing out of changes. [(Martin Fowler)](https://www.martinfowler.com/eaaCatalog/unitOfWork.html)
|
|
23
|
+
|
|
24
|
+
> Identity Map ensures that each object (_entity_) gets loaded only once by keeping every
|
|
25
|
+
> loaded object in a map. Looks up objects using the map when referring to them.
|
|
26
|
+
> [(Martin Fowler)](https://www.martinfowler.com/eaaCatalog/identityMap.html)
|
|
27
|
+
|
|
28
|
+
So what benefits does it bring to us?
|
|
29
|
+
|
|
30
|
+
### Implicit Transactions
|
|
31
|
+
|
|
32
|
+
First and most important implication of having Unit of Work is that it allows handling transactions automatically.
|
|
33
|
+
|
|
34
|
+
When you call `em.flush()`, all computed changes are queried inside a database transaction (if supported by given driver). This means that you can control the boundaries of transactions simply by calling `em.persistLater()` and once all your changes are ready, calling `flush()` will run them inside a transaction.
|
|
35
|
+
|
|
36
|
+
> You can also control the transaction boundaries manually via `em.transactional(cb)`.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const user = await em.findOneOrFail(User, 1);
|
|
40
|
+
user.email = 'foo@bar.com';
|
|
41
|
+
const car = new Car();
|
|
42
|
+
user.cars.add(car);
|
|
43
|
+
|
|
44
|
+
// thanks to bi-directional cascading we only need to persist user entity
|
|
45
|
+
// flushing will create a transaction, insert new car and update user with new email
|
|
46
|
+
// as user entity is managed, calling flush() is enough
|
|
47
|
+
await em.flush();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### ChangeSet based persistence
|
|
51
|
+
|
|
52
|
+
MikroORM allows you to implement your domain/business logic directly in the entities. To maintain always valid entities, you can use constructors to mark required properties. Let's define the `User` entity used in previous example:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
@Entity()
|
|
56
|
+
export class User {
|
|
57
|
+
|
|
58
|
+
@PrimaryKey()
|
|
59
|
+
id!: number;
|
|
60
|
+
|
|
61
|
+
@Property()
|
|
62
|
+
name!: string;
|
|
63
|
+
|
|
64
|
+
@OneToOne(() => Address)
|
|
65
|
+
address?: Address;
|
|
66
|
+
|
|
67
|
+
@ManyToMany(() => Car)
|
|
68
|
+
cars = new Collection<Car>(this);
|
|
69
|
+
|
|
70
|
+
constructor(name: string) {
|
|
71
|
+
this.name = name;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Now to create new instance of the `User` entity, we are forced to provide the `name`:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const user = new User('John Doe'); // name is required to create new user instance
|
|
81
|
+
user.address = new Address('10 Downing Street'); // address is optional
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Once your entities are loaded, make a number of synchronous actions on your entities,
|
|
85
|
+
then call `em.flush()`. This will trigger computing of change sets. Only entities
|
|
86
|
+
(and properties) that were changed will generate database queries, if there are no changes,
|
|
87
|
+
no transaction will be started.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const user = await em.findOneOrFail(User, 1, {
|
|
91
|
+
populate: ['cars', 'address.city'],
|
|
92
|
+
});
|
|
93
|
+
user.title = 'Mr.';
|
|
94
|
+
user.address.street = '10 Downing Street'; // address is 1:1 relation of Address entity
|
|
95
|
+
user.cars.getItems().forEach(car => car.forSale = true); // cars is 1:m collection of Car entities
|
|
96
|
+
const car = new Car('VW');
|
|
97
|
+
user.cars.add(car);
|
|
98
|
+
|
|
99
|
+
// now we can flush all changes done to managed entities
|
|
100
|
+
await em.flush();
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`em.flush()` will then execute these queries from the example above:
|
|
104
|
+
|
|
105
|
+
```sql
|
|
106
|
+
begin;
|
|
107
|
+
update "user" set "title" = 'Mr.' where "id" = 1;
|
|
108
|
+
update "user_address" set "street" = '10 Downing Street' where "id" = 123;
|
|
109
|
+
update "car"
|
|
110
|
+
set "for_sale" = case
|
|
111
|
+
when ("id" = 1) then true
|
|
112
|
+
when ("id" = 2) then true
|
|
113
|
+
when ("id" = 3) then true
|
|
114
|
+
else "for_sale" end
|
|
115
|
+
where "id" in (1, 2, 3)
|
|
116
|
+
insert into "car" ("brand", "owner") values ('VW', 1);
|
|
117
|
+
commit;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Identity Map
|
|
121
|
+
|
|
122
|
+
Thanks to Identity Map, you will always have only one instance of given entity in one context. This allows for some optimizations (skipping loading of already loaded entities), as well as comparison by identity (`ent1 === ent2`).
|
|
123
|
+
|
|
124
|
+
## 📖 Documentation
|
|
125
|
+
|
|
126
|
+
MikroORM documentation, included in this repo in the root directory, is built with [Docusaurus](https://docusaurus.io) and publicly hosted on GitHub Pages at https://mikro-orm.io.
|
|
127
|
+
|
|
128
|
+
There is also auto-generated [CHANGELOG.md](CHANGELOG.md) file based on commit messages (via `semantic-release`).
|
|
129
|
+
|
|
130
|
+
## ✨ Core Features
|
|
131
|
+
|
|
132
|
+
- [Clean and Simple Entity Definition](https://mikro-orm.io/docs/defining-entities)
|
|
133
|
+
- [Identity Map](https://mikro-orm.io/docs/identity-map)
|
|
134
|
+
- [Entity References](https://mikro-orm.io/docs/entity-references)
|
|
135
|
+
- [Using Entity Constructors](https://mikro-orm.io/docs/entity-constructors)
|
|
136
|
+
- [Modelling Relationships](https://mikro-orm.io/docs/relationships)
|
|
137
|
+
- [Collections](https://mikro-orm.io/docs/collections)
|
|
138
|
+
- [Unit of Work](https://mikro-orm.io/docs/unit-of-work)
|
|
139
|
+
- [Transactions](https://mikro-orm.io/docs/transactions)
|
|
140
|
+
- [Cascading persist and remove](https://mikro-orm.io/docs/cascading)
|
|
141
|
+
- [Composite and Foreign Keys as Primary Key](https://mikro-orm.io/docs/composite-keys)
|
|
142
|
+
- [Filters](https://mikro-orm.io/docs/filters)
|
|
143
|
+
- [Using `QueryBuilder`](https://mikro-orm.io/docs/query-builder)
|
|
144
|
+
- [Preloading Deeply Nested Structures via populate](https://mikro-orm.io/docs/nested-populate)
|
|
145
|
+
- [Property Validation](https://mikro-orm.io/docs/property-validation)
|
|
146
|
+
- [Lifecycle Hooks](https://mikro-orm.io/docs/lifecycle-hooks)
|
|
147
|
+
- [Vanilla JS Support](https://mikro-orm.io/docs/usage-with-js)
|
|
148
|
+
- [Schema Generator](https://mikro-orm.io/docs/schema-generator)
|
|
149
|
+
- [Entity Generator](https://mikro-orm.io/docs/entity-generator)
|
|
150
|
+
|
|
151
|
+
## 📦 Example Integrations
|
|
152
|
+
|
|
153
|
+
You can find example integrations for some popular frameworks in the [`mikro-orm-examples` repository](https://github.com/mikro-orm/mikro-orm-examples):
|
|
154
|
+
|
|
155
|
+
### TypeScript Examples
|
|
156
|
+
|
|
157
|
+
- [Express + MongoDB](https://github.com/mikro-orm/express-ts-example-app)
|
|
158
|
+
- [Nest + MySQL](https://github.com/mikro-orm/nestjs-example-app)
|
|
159
|
+
- [RealWorld example app (Nest + MySQL)](https://github.com/mikro-orm/nestjs-realworld-example-app)
|
|
160
|
+
- [Koa + SQLite](https://github.com/mikro-orm/koa-ts-example-app)
|
|
161
|
+
- [GraphQL + PostgreSQL](https://github.com/driescroons/mikro-orm-graphql-example)
|
|
162
|
+
- [Inversify + PostgreSQL](https://github.com/PodaruDragos/inversify-example-app)
|
|
163
|
+
- [NextJS + MySQL](https://github.com/jonahallibone/mikro-orm-nextjs)
|
|
164
|
+
- [Accounts.js REST and GraphQL authentication + SQLite](https://github.com/darkbasic/mikro-orm-accounts-example)
|
|
165
|
+
- [Nest + Shopify + PostgreSQL + GraphQL](https://github.com/Cloudshelf/Shopify_CSConnector)
|
|
166
|
+
|
|
167
|
+
### JavaScript Examples
|
|
168
|
+
|
|
169
|
+
- [Express + SQLite](https://github.com/mikro-orm/express-js-example-app)
|
|
170
|
+
|
|
171
|
+
## 🚀 Quick Start
|
|
172
|
+
|
|
173
|
+
First install the module via `yarn` or `npm` and do not forget to install the database driver as well:
|
|
174
|
+
|
|
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
|
+
|
|
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
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
or
|
|
186
|
+
|
|
187
|
+
```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
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
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:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
"experimentalDecorators": true,
|
|
199
|
+
"emitDecoratorMetadata": true,
|
|
200
|
+
"esModuleInterop": true,
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Alternatively, you can use [`EntitySchema`](https://mikro-orm.io/docs/entity-schema).
|
|
204
|
+
|
|
205
|
+
Then call `MikroORM.init` as part of bootstrapping your app:
|
|
206
|
+
|
|
207
|
+
> To access driver specific methods like `em.createQueryBuilder()` we need to specify the driver type when calling `MikroORM.init()`. Alternatively we can cast the `orm.em` to `EntityManager` exported from the driver package:
|
|
208
|
+
>
|
|
209
|
+
> ```ts
|
|
210
|
+
> import { EntityManager } from '@mikro-orm/postgresql';
|
|
211
|
+
> const em = orm.em as EntityManager;
|
|
212
|
+
> const qb = em.createQueryBuilder(...);
|
|
213
|
+
> ```
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import type { PostgreSqlDriver } from '@mikro-orm/postgresql'; // or any other SQL driver package
|
|
217
|
+
|
|
218
|
+
const orm = await MikroORM.init<PostgreSqlDriver>({
|
|
219
|
+
entities: ['./dist/entities'], // path to your JS entities (dist), relative to `baseDir`
|
|
220
|
+
dbName: 'my-db-name',
|
|
221
|
+
type: 'postgresql',
|
|
222
|
+
});
|
|
223
|
+
console.log(orm.em); // access EntityManager via `em` property
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
There are more ways to configure your entities, take a look at [installation page](https://mikro-orm.io/docs/installation/).
|
|
227
|
+
|
|
228
|
+
> Read more about all the possible configuration options in [Advanced Configuration](https://mikro-orm.io/docs/configuration) section.
|
|
229
|
+
|
|
230
|
+
Then you will need to fork entity manager for each request so their [identity maps](https://mikro-orm.io/docs/identity-map/) will not collide. To do so, use the `RequestContext` helper:
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
const app = express();
|
|
234
|
+
|
|
235
|
+
app.use((req, res, next) => {
|
|
236
|
+
RequestContext.create(orm.em, next);
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
> You should register this middleware as the last one just before request handlers and before any of your custom middleware that is using the ORM. There might be issues when you register it before request processing middleware like `queryParser` or `bodyParser`, so definitely register the context after them.
|
|
241
|
+
|
|
242
|
+
More info about `RequestContext` is described [here](https://mikro-orm.io/docs/identity-map/#request-context).
|
|
243
|
+
|
|
244
|
+
Now you can start defining your entities (in one of the `entities` folders). This is how simple entity can look like in mongo driver:
|
|
245
|
+
|
|
246
|
+
**`./entities/MongoBook.ts`**
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
@Entity()
|
|
250
|
+
export class MongoBook {
|
|
251
|
+
|
|
252
|
+
@PrimaryKey()
|
|
253
|
+
_id: ObjectID;
|
|
254
|
+
|
|
255
|
+
@SerializedPrimaryKey()
|
|
256
|
+
id: string;
|
|
257
|
+
|
|
258
|
+
@Property()
|
|
259
|
+
title: string;
|
|
260
|
+
|
|
261
|
+
@ManyToOne(() => Author)
|
|
262
|
+
author: Author;
|
|
263
|
+
|
|
264
|
+
@ManyToMany(() => BookTag)
|
|
265
|
+
tags = new Collection<BookTag>(this);
|
|
266
|
+
|
|
267
|
+
constructor(title: string, author: Author) {
|
|
268
|
+
this.title = title;
|
|
269
|
+
this.author = author;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
For SQL drivers, you can use `id: number` PK:
|
|
276
|
+
|
|
277
|
+
**`./entities/SqlBook.ts`**
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
@Entity()
|
|
281
|
+
export class SqlBook {
|
|
282
|
+
|
|
283
|
+
@PrimaryKey()
|
|
284
|
+
id: number;
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Or if you want to use UUID primary keys:
|
|
290
|
+
|
|
291
|
+
**`./entities/UuidBook.ts`**
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { v4 } from 'uuid';
|
|
295
|
+
|
|
296
|
+
@Entity()
|
|
297
|
+
export class UuidBook {
|
|
298
|
+
|
|
299
|
+
@PrimaryKey()
|
|
300
|
+
uuid = v4();
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
More information can be found in [defining entities section](https://mikro-orm.io/docs/defining-entities/) in docs.
|
|
306
|
+
|
|
307
|
+
When you have your entities defined, you can start using ORM either via `EntityManager` or via `EntityRepository`s.
|
|
308
|
+
|
|
309
|
+
To save entity state to database, you need to persist it. Persist takes care or deciding whether to use `insert` or `update` and computes appropriate change-set. Entity references that are not persisted yet (does not have identifier) will be cascade persisted automatically.
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
// use constructors in your entities for required parameters
|
|
313
|
+
const author = new Author('Jon Snow', 'snow@wall.st');
|
|
314
|
+
author.born = new Date();
|
|
315
|
+
|
|
316
|
+
const publisher = new Publisher('7K publisher');
|
|
317
|
+
|
|
318
|
+
const book1 = new Book('My Life on The Wall, part 1', author);
|
|
319
|
+
book1.publisher = publisher;
|
|
320
|
+
const book2 = new Book('My Life on The Wall, part 2', author);
|
|
321
|
+
book2.publisher = publisher;
|
|
322
|
+
const book3 = new Book('My Life on The Wall, part 3', author);
|
|
323
|
+
book3.publisher = publisher;
|
|
324
|
+
|
|
325
|
+
// just persist books, author and publisher will be automatically cascade persisted
|
|
326
|
+
await em.persistAndFlush([book1, book2, book3]);
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
To fetch entities from database you can use `find()` and `findOne()` of `EntityManager`:
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
const authors = em.find(Author, {}, { populate: ['books'] });
|
|
333
|
+
|
|
334
|
+
for (const author of authors) {
|
|
335
|
+
console.log(author); // instance of Author entity
|
|
336
|
+
console.log(author.name); // Jon Snow
|
|
337
|
+
|
|
338
|
+
for (const book of author.books) { // iterating books collection
|
|
339
|
+
console.log(book); // instance of Book entity
|
|
340
|
+
console.log(book.title); // My Life on The Wall, part 1/2/3
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
More convenient way of fetching entities from database is by using `EntityRepository`, that carries the entity name, so you do not have to pass it to every `find` and `findOne` calls:
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
const booksRepository = em.getRepository(Book);
|
|
349
|
+
|
|
350
|
+
const books = await booksRepository.find({ author: '...' }, {
|
|
351
|
+
populate: ['author'],
|
|
352
|
+
limit: 1,
|
|
353
|
+
offset: 2,
|
|
354
|
+
orderBy: { title: QueryOrder.DESC },
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
console.log(books); // Loaded<Book, 'author'>[]
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Take a look at docs about [working with `EntityManager`](https://mikro-orm.io/docs/entity-manager/) or [using `EntityRepository` instead](https://mikro-orm.io/docs/repositories/).
|
|
361
|
+
|
|
362
|
+
## 🤝 Contributing
|
|
363
|
+
|
|
364
|
+
Contributions, issues and feature requests are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for submitting pull requests to us.
|
|
365
|
+
|
|
366
|
+
## Authors
|
|
367
|
+
|
|
368
|
+
👤 **Martin Adámek**
|
|
369
|
+
|
|
370
|
+
- Twitter: [@B4nan](https://twitter.com/B4nan)
|
|
371
|
+
- Github: [@b4nan](https://github.com/b4nan)
|
|
372
|
+
|
|
373
|
+
See also the list of contributors who [participated](https://github.com/mikro-orm/mikro-orm/contributors) in this project.
|
|
374
|
+
|
|
375
|
+
## Show Your Support
|
|
376
|
+
|
|
377
|
+
Please ⭐️ this repository if this project helped you!
|
|
378
|
+
|
|
379
|
+
## 📝 License
|
|
380
|
+
|
|
381
|
+
Copyright © 2018 [Martin Adámek](https://github.com/b4nan).
|
|
382
|
+
|
|
383
|
+
This project is licensed under the MIT License - see the [LICENSE file](LICENSE) for details.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "@yandjin-mikro-orm/knex";
|
|
2
|
+
export * from "./BetterSqliteConnection";
|
|
3
|
+
export * from "./BetterSqliteDriver";
|
|
4
|
+
export * from "./BetterSqlitePlatform";
|
|
5
|
+
export * from "./BetterSqliteSchemaHelper";
|
|
6
|
+
export * from "./BetterSqliteExceptionConverter";
|
|
7
|
+
export { BetterSqliteMikroORM as MikroORM, BetterSqliteOptions as Options, defineBetterSqliteConfig as defineConfig, } from "./BetterSqliteMikroORM";
|
package/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.defineConfig = exports.MikroORM = void 0;
|
|
18
|
+
__exportStar(require("@yandjin-mikro-orm/knex"), exports);
|
|
19
|
+
__exportStar(require("./BetterSqliteConnection"), exports);
|
|
20
|
+
__exportStar(require("./BetterSqliteDriver"), exports);
|
|
21
|
+
__exportStar(require("./BetterSqlitePlatform"), exports);
|
|
22
|
+
__exportStar(require("./BetterSqliteSchemaHelper"), exports);
|
|
23
|
+
__exportStar(require("./BetterSqliteExceptionConverter"), exports);
|
|
24
|
+
var BetterSqliteMikroORM_1 = require("./BetterSqliteMikroORM");
|
|
25
|
+
Object.defineProperty(exports, "MikroORM", { enumerable: true, get: function () { return BetterSqliteMikroORM_1.BetterSqliteMikroORM; } });
|
|
26
|
+
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return BetterSqliteMikroORM_1.defineBetterSqliteConfig; } });
|
package/index.mjs
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import mod from "./index.js";
|
|
2
|
+
|
|
3
|
+
export default mod;
|
|
4
|
+
export const ALIAS_REPLACEMENT = mod.ALIAS_REPLACEMENT;
|
|
5
|
+
export const ALIAS_REPLACEMENT_RE = mod.ALIAS_REPLACEMENT_RE;
|
|
6
|
+
export const ARRAY_OPERATORS = mod.ARRAY_OPERATORS;
|
|
7
|
+
export const AbstractNamingStrategy = mod.AbstractNamingStrategy;
|
|
8
|
+
export const AbstractSchemaGenerator = mod.AbstractSchemaGenerator;
|
|
9
|
+
export const AbstractSqlConnection = mod.AbstractSqlConnection;
|
|
10
|
+
export const AbstractSqlDriver = mod.AbstractSqlDriver;
|
|
11
|
+
export const AbstractSqlPlatform = mod.AbstractSqlPlatform;
|
|
12
|
+
export const AfterCreate = mod.AfterCreate;
|
|
13
|
+
export const AfterDelete = mod.AfterDelete;
|
|
14
|
+
export const AfterUpdate = mod.AfterUpdate;
|
|
15
|
+
export const AfterUpsert = mod.AfterUpsert;
|
|
16
|
+
export const ArrayCollection = mod.ArrayCollection;
|
|
17
|
+
export const ArrayCriteriaNode = mod.ArrayCriteriaNode;
|
|
18
|
+
export const ArrayType = mod.ArrayType;
|
|
19
|
+
export const BaseEntity = mod.BaseEntity;
|
|
20
|
+
export const BeforeCreate = mod.BeforeCreate;
|
|
21
|
+
export const BeforeDelete = mod.BeforeDelete;
|
|
22
|
+
export const BeforeUpdate = mod.BeforeUpdate;
|
|
23
|
+
export const BeforeUpsert = mod.BeforeUpsert;
|
|
24
|
+
export const BetterSqliteConnection = mod.BetterSqliteConnection;
|
|
25
|
+
export const BetterSqliteDriver = mod.BetterSqliteDriver;
|
|
26
|
+
export const BetterSqliteExceptionConverter = mod.BetterSqliteExceptionConverter;
|
|
27
|
+
export const BetterSqlitePlatform = mod.BetterSqlitePlatform;
|
|
28
|
+
export const BetterSqliteSchemaHelper = mod.BetterSqliteSchemaHelper;
|
|
29
|
+
export const BigIntType = mod.BigIntType;
|
|
30
|
+
export const BlobType = mod.BlobType;
|
|
31
|
+
export const BooleanType = mod.BooleanType;
|
|
32
|
+
export const Cascade = mod.Cascade;
|
|
33
|
+
export const ChangeSet = mod.ChangeSet;
|
|
34
|
+
export const ChangeSetComputer = mod.ChangeSetComputer;
|
|
35
|
+
export const ChangeSetPersister = mod.ChangeSetPersister;
|
|
36
|
+
export const ChangeSetType = mod.ChangeSetType;
|
|
37
|
+
export const Check = mod.Check;
|
|
38
|
+
export const CheckConstraintViolationException = mod.CheckConstraintViolationException;
|
|
39
|
+
export const Collection = mod.Collection;
|
|
40
|
+
export const CommitOrderCalculator = mod.CommitOrderCalculator;
|
|
41
|
+
export const Config = mod.Config;
|
|
42
|
+
export const Configuration = mod.Configuration;
|
|
43
|
+
export const ConfigurationLoader = mod.ConfigurationLoader;
|
|
44
|
+
export const Connection = mod.Connection;
|
|
45
|
+
export const ConnectionException = mod.ConnectionException;
|
|
46
|
+
export const ConstraintViolationException = mod.ConstraintViolationException;
|
|
47
|
+
export const CreateRequestContext = mod.CreateRequestContext;
|
|
48
|
+
export const CriteriaNode = mod.CriteriaNode;
|
|
49
|
+
export const CriteriaNodeFactory = mod.CriteriaNodeFactory;
|
|
50
|
+
export const Cursor = mod.Cursor;
|
|
51
|
+
export const CursorError = mod.CursorError;
|
|
52
|
+
export const DatabaseDriver = mod.DatabaseDriver;
|
|
53
|
+
export const DatabaseObjectExistsException = mod.DatabaseObjectExistsException;
|
|
54
|
+
export const DatabaseObjectNotFoundException = mod.DatabaseObjectNotFoundException;
|
|
55
|
+
export const DatabaseSchema = mod.DatabaseSchema;
|
|
56
|
+
export const DatabaseTable = mod.DatabaseTable;
|
|
57
|
+
export const DataloaderType = mod.DataloaderType;
|
|
58
|
+
export const DataloaderUtils = mod.DataloaderUtils;
|
|
59
|
+
export const DateTimeType = mod.DateTimeType;
|
|
60
|
+
export const DateType = mod.DateType;
|
|
61
|
+
export const DeadlockException = mod.DeadlockException;
|
|
62
|
+
export const DecimalType = mod.DecimalType;
|
|
63
|
+
export const DefaultLogger = mod.DefaultLogger;
|
|
64
|
+
export const DoubleType = mod.DoubleType;
|
|
65
|
+
export const DriverException = mod.DriverException;
|
|
66
|
+
export const EagerProps = mod.EagerProps;
|
|
67
|
+
export const Embeddable = mod.Embeddable;
|
|
68
|
+
export const Embedded = mod.Embedded;
|
|
69
|
+
export const EnsureRequestContext = mod.EnsureRequestContext;
|
|
70
|
+
export const Entity = mod.Entity;
|
|
71
|
+
export const EntityAssigner = mod.EntityAssigner;
|
|
72
|
+
export const EntityCaseNamingStrategy = mod.EntityCaseNamingStrategy;
|
|
73
|
+
export const EntityComparator = mod.EntityComparator;
|
|
74
|
+
export const EntityFactory = mod.EntityFactory;
|
|
75
|
+
export const EntityHelper = mod.EntityHelper;
|
|
76
|
+
export const EntityIdentifier = mod.EntityIdentifier;
|
|
77
|
+
export const EntityLoader = mod.EntityLoader;
|
|
78
|
+
export const EntityManager = mod.EntityManager;
|
|
79
|
+
export const EntityManagerType = mod.EntityManagerType;
|
|
80
|
+
export const EntityMetadata = mod.EntityMetadata;
|
|
81
|
+
export const EntityRepository = mod.EntityRepository;
|
|
82
|
+
export const EntityRepositoryType = mod.EntityRepositoryType;
|
|
83
|
+
export const EntitySchema = mod.EntitySchema;
|
|
84
|
+
export const EntitySerializer = mod.EntitySerializer;
|
|
85
|
+
export const EntityTransformer = mod.EntityTransformer;
|
|
86
|
+
export const EntityValidator = mod.EntityValidator;
|
|
87
|
+
export const Enum = mod.Enum;
|
|
88
|
+
export const EnumArrayType = mod.EnumArrayType;
|
|
89
|
+
export const EnumType = mod.EnumType;
|
|
90
|
+
export const EventManager = mod.EventManager;
|
|
91
|
+
export const EventType = mod.EventType;
|
|
92
|
+
export const EventTypeMap = mod.EventTypeMap;
|
|
93
|
+
export const ExceptionConverter = mod.ExceptionConverter;
|
|
94
|
+
export const FileCacheAdapter = mod.FileCacheAdapter;
|
|
95
|
+
export const Filter = mod.Filter;
|
|
96
|
+
export const FloatType = mod.FloatType;
|
|
97
|
+
export const FlushMode = mod.FlushMode;
|
|
98
|
+
export const ForeignKeyConstraintViolationException = mod.ForeignKeyConstraintViolationException;
|
|
99
|
+
export const Formula = mod.Formula;
|
|
100
|
+
export const GeneratedCacheAdapter = mod.GeneratedCacheAdapter;
|
|
101
|
+
export const GroupOperator = mod.GroupOperator;
|
|
102
|
+
export const HiddenProps = mod.HiddenProps;
|
|
103
|
+
export const Hydrator = mod.Hydrator;
|
|
104
|
+
export const IdentityMap = mod.IdentityMap;
|
|
105
|
+
export const Index = mod.Index;
|
|
106
|
+
export const IntegerType = mod.IntegerType;
|
|
107
|
+
export const IntervalType = mod.IntervalType;
|
|
108
|
+
export const InvalidFieldNameException = mod.InvalidFieldNameException;
|
|
109
|
+
export const IsolationLevel = mod.IsolationLevel;
|
|
110
|
+
export const JoinType = mod.JoinType;
|
|
111
|
+
export const JsonProperty = mod.JsonProperty;
|
|
112
|
+
export const JsonType = mod.JsonType;
|
|
113
|
+
export const Knex = mod.Knex;
|
|
114
|
+
export const LoadStrategy = mod.LoadStrategy;
|
|
115
|
+
export const LockMode = mod.LockMode;
|
|
116
|
+
export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
|
|
117
|
+
export const ManyToMany = mod.ManyToMany;
|
|
118
|
+
export const ManyToOne = mod.ManyToOne;
|
|
119
|
+
export const MediumIntType = mod.MediumIntType;
|
|
120
|
+
export const MemoryCacheAdapter = mod.MemoryCacheAdapter;
|
|
121
|
+
export const MetadataDiscovery = mod.MetadataDiscovery;
|
|
122
|
+
export const MetadataError = mod.MetadataError;
|
|
123
|
+
export const MetadataProvider = mod.MetadataProvider;
|
|
124
|
+
export const MetadataStorage = mod.MetadataStorage;
|
|
125
|
+
export const MetadataValidator = mod.MetadataValidator;
|
|
126
|
+
export const MikroORM = mod.MikroORM;
|
|
127
|
+
export const MongoNamingStrategy = mod.MongoNamingStrategy;
|
|
128
|
+
export const MonkeyPatchable = mod.MonkeyPatchable;
|
|
129
|
+
export const NodeState = mod.NodeState;
|
|
130
|
+
export const NonUniqueFieldNameException = mod.NonUniqueFieldNameException;
|
|
131
|
+
export const NotFoundError = mod.NotFoundError;
|
|
132
|
+
export const NotNullConstraintViolationException = mod.NotNullConstraintViolationException;
|
|
133
|
+
export const NullCacheAdapter = mod.NullCacheAdapter;
|
|
134
|
+
export const NullHighlighter = mod.NullHighlighter;
|
|
135
|
+
export const ObjectBindingPattern = mod.ObjectBindingPattern;
|
|
136
|
+
export const ObjectCriteriaNode = mod.ObjectCriteriaNode;
|
|
137
|
+
export const ObjectHydrator = mod.ObjectHydrator;
|
|
138
|
+
export const OnInit = mod.OnInit;
|
|
139
|
+
export const OnLoad = mod.OnLoad;
|
|
140
|
+
export const OneToMany = mod.OneToMany;
|
|
141
|
+
export const OneToOne = mod.OneToOne;
|
|
142
|
+
export const OptimisticLockError = mod.OptimisticLockError;
|
|
143
|
+
export const OptionalProps = mod.OptionalProps;
|
|
144
|
+
export const PlainObject = mod.PlainObject;
|
|
145
|
+
export const Platform = mod.Platform;
|
|
146
|
+
export const PopulateHint = mod.PopulateHint;
|
|
147
|
+
export const PrimaryKey = mod.PrimaryKey;
|
|
148
|
+
export const PrimaryKeyProp = mod.PrimaryKeyProp;
|
|
149
|
+
export const Property = mod.Property;
|
|
150
|
+
export const QueryBuilder = mod.QueryBuilder;
|
|
151
|
+
export const QueryBuilderHelper = mod.QueryBuilderHelper;
|
|
152
|
+
export const QueryFlag = mod.QueryFlag;
|
|
153
|
+
export const QueryHelper = mod.QueryHelper;
|
|
154
|
+
export const QueryOperator = mod.QueryOperator;
|
|
155
|
+
export const QueryOrder = mod.QueryOrder;
|
|
156
|
+
export const QueryOrderNumeric = mod.QueryOrderNumeric;
|
|
157
|
+
export const QueryType = mod.QueryType;
|
|
158
|
+
export const RawQueryFragment = mod.RawQueryFragment;
|
|
159
|
+
export const ReadOnlyException = mod.ReadOnlyException;
|
|
160
|
+
export const Ref = mod.Ref;
|
|
161
|
+
export const Reference = mod.Reference;
|
|
162
|
+
export const ReferenceKind = mod.ReferenceKind;
|
|
163
|
+
export const ReflectMetadataProvider = mod.ReflectMetadataProvider;
|
|
164
|
+
export const RequestContext = mod.RequestContext;
|
|
165
|
+
export const SCALAR_TYPES = mod.SCALAR_TYPES;
|
|
166
|
+
export const ScalarCriteriaNode = mod.ScalarCriteriaNode;
|
|
167
|
+
export const ScalarReference = mod.ScalarReference;
|
|
168
|
+
export const SchemaComparator = mod.SchemaComparator;
|
|
169
|
+
export const SchemaGenerator = mod.SchemaGenerator;
|
|
170
|
+
export const SchemaHelper = mod.SchemaHelper;
|
|
171
|
+
export const SerializationContext = mod.SerializationContext;
|
|
172
|
+
export const SerializedPrimaryKey = mod.SerializedPrimaryKey;
|
|
173
|
+
export const ServerException = mod.ServerException;
|
|
174
|
+
export const SimpleLogger = mod.SimpleLogger;
|
|
175
|
+
export const SmallIntType = mod.SmallIntType;
|
|
176
|
+
export const SqlEntityManager = mod.SqlEntityManager;
|
|
177
|
+
export const SqlEntityRepository = mod.SqlEntityRepository;
|
|
178
|
+
export const SqlSchemaGenerator = mod.SqlSchemaGenerator;
|
|
179
|
+
export const StringType = mod.StringType;
|
|
180
|
+
export const SyntaxErrorException = mod.SyntaxErrorException;
|
|
181
|
+
export const TableExistsException = mod.TableExistsException;
|
|
182
|
+
export const TableNotFoundException = mod.TableNotFoundException;
|
|
183
|
+
export const TextType = mod.TextType;
|
|
184
|
+
export const TimeType = mod.TimeType;
|
|
185
|
+
export const TinyIntType = mod.TinyIntType;
|
|
186
|
+
export const TransactionContext = mod.TransactionContext;
|
|
187
|
+
export const TransactionEventBroadcaster = mod.TransactionEventBroadcaster;
|
|
188
|
+
export const Type = mod.Type;
|
|
189
|
+
export const Uint8ArrayType = mod.Uint8ArrayType;
|
|
190
|
+
export const UnderscoreNamingStrategy = mod.UnderscoreNamingStrategy;
|
|
191
|
+
export const Unique = mod.Unique;
|
|
192
|
+
export const UniqueConstraintViolationException = mod.UniqueConstraintViolationException;
|
|
193
|
+
export const UnitOfWork = mod.UnitOfWork;
|
|
194
|
+
export const UnknownType = mod.UnknownType;
|
|
195
|
+
export const Utils = mod.Utils;
|
|
196
|
+
export const UuidType = mod.UuidType;
|
|
197
|
+
export const ValidationError = mod.ValidationError;
|
|
198
|
+
export const WrappedEntity = mod.WrappedEntity;
|
|
199
|
+
export const assign = mod.assign;
|
|
200
|
+
export const colors = mod.colors;
|
|
201
|
+
export const compareArrays = mod.compareArrays;
|
|
202
|
+
export const compareBooleans = mod.compareBooleans;
|
|
203
|
+
export const compareBuffers = mod.compareBuffers;
|
|
204
|
+
export const compareObjects = mod.compareObjects;
|
|
205
|
+
export const createSqlFunction = mod.createSqlFunction;
|
|
206
|
+
export const defineConfig = mod.defineConfig;
|
|
207
|
+
export const equals = mod.equals;
|
|
208
|
+
export const getOnConflictFields = mod.getOnConflictFields;
|
|
209
|
+
export const getOnConflictReturningFields = mod.getOnConflictReturningFields;
|
|
210
|
+
export const helper = mod.helper;
|
|
211
|
+
export const knex = mod.knex;
|
|
212
|
+
export const parseJsonSafe = mod.parseJsonSafe;
|
|
213
|
+
export const raw = mod.raw;
|
|
214
|
+
export const ref = mod.ref;
|
|
215
|
+
export const rel = mod.rel;
|
|
216
|
+
export const serialize = mod.serialize;
|
|
217
|
+
export const sql = mod.sql;
|
|
218
|
+
export const t = mod.t;
|
|
219
|
+
export const types = mod.types;
|
|
220
|
+
export const wrap = mod.wrap;
|