nestjs-typeorm3-kit 0.1.2 → 0.1.3
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/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# nestjs-typeorm3-kit
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/nestjs-typeorm3-kit) 
|
|
4
|
+
|
|
5
|
+
## [Node.js] nestjs-typeorm3-kit
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
#### NPM
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install nestjs-typeorm3-kit typeorm-transactional
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
#### Yarn
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add nestjs-typeorm3-kit typeorm-transactional
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### pnpm
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add nestjs-typeorm3-kit typeorm-transactional
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### bun
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add nestjs-typeorm3-kit typeorm-transactional
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Config after install
|
|
34
|
+
|
|
35
|
+
#### Use @DefEntityRepository
|
|
36
|
+
|
|
37
|
+
For using `@DefEntityRepository` instead of `@EntityRepository` of typeorm 0.2, you need to add the following code in `main.ts` or `app.module.ts`:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { TypeOrmModule } from "@nestjs/typeorm";
|
|
41
|
+
|
|
42
|
+
TypeOrmModule.forRootAsync({
|
|
43
|
+
useFactory: () => ({
|
|
44
|
+
type: "postgres",
|
|
45
|
+
host: "localhost",
|
|
46
|
+
port: 5432,
|
|
47
|
+
username: "postgres",
|
|
48
|
+
password: "Abc12345",
|
|
49
|
+
database: "primary_db",
|
|
50
|
+
entities: [join(__dirname, "./domains/primary/**/*.entity.{ts,js}")],
|
|
51
|
+
synchronize: true,
|
|
52
|
+
autoLoadEntities: true,
|
|
53
|
+
retryAttempts: 2,
|
|
54
|
+
retryDelay: 1000,
|
|
55
|
+
}),
|
|
56
|
+
dataSourceFactory: async (options: DataSourceOptions) => {
|
|
57
|
+
if (!options) {
|
|
58
|
+
throw new Error("Invalid options passed");
|
|
59
|
+
}
|
|
60
|
+
return addTransactionalDataSource({
|
|
61
|
+
dataSource: new DataSource(options),
|
|
62
|
+
name: PRIMARY_CONNECTION,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### create Repository module Use @DefRepositoryModule
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { Module } from "@nestjs/common";
|
|
72
|
+
import { join } from "path";
|
|
73
|
+
|
|
74
|
+
import { PRIMARY_CONNECTION } from "~/common/constants";
|
|
75
|
+
import { DefRepositoryModule } from "nestjs-typeorm3-kit";
|
|
76
|
+
@Module({
|
|
77
|
+
imports: [
|
|
78
|
+
DefRepositoryModule.forRootAsync({
|
|
79
|
+
useFactory: () => ({
|
|
80
|
+
globPattern: join(__dirname, "./**/*.repo.{ts,js}"),
|
|
81
|
+
dataSource: PRIMARY_CONNECTION,
|
|
82
|
+
}),
|
|
83
|
+
}),
|
|
84
|
+
],
|
|
85
|
+
exports: [DefRepositoryModule],
|
|
86
|
+
})
|
|
87
|
+
export class PrimaryRepoModule {}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
or
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Module } from "@nestjs/common";
|
|
94
|
+
import { join } from "path";
|
|
95
|
+
|
|
96
|
+
import { PRIMARY_CONNECTION } from "~/common/constants";
|
|
97
|
+
import { DefRepositoryModule } from "nestjs-typeorm3-kit";
|
|
98
|
+
@Module({
|
|
99
|
+
imports: [
|
|
100
|
+
DefRepositoryModule.forFeature([BookRepo, PhotoRepo], PRIMARY_CONNECTION),
|
|
101
|
+
],
|
|
102
|
+
exports: [DefRepositoryModule],
|
|
103
|
+
})
|
|
104
|
+
export class PrimaryRepoModule {}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Example
|
|
108
|
+
|
|
109
|
+
[Example](./example)
|
|
110
|
+
|
|
111
|
+
### Full document in wiki github
|
|
112
|
+
|
|
113
|
+
[FULL DOCUMENT](https://x302502.github.io/nestjs-typeorm3-kit/)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,wBAAgB,uBAAuB,SAEtC;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addTransactionalDataSource = void 0;
|
|
3
4
|
exports.setupTransactionContext = setupTransactionContext;
|
|
4
5
|
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
6
|
+
Object.defineProperty(exports, "addTransactionalDataSource", { enumerable: true, get: function () { return typeorm_transactional_1.addTransactionalDataSource; } });
|
|
5
7
|
function setupTransactionContext() {
|
|
6
8
|
(0, typeorm_transactional_1.initializeTransactionalContext)();
|
|
7
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":";;;AAIA,0DAEC;AAND,iEAG+B;AAKtB,2GANP,kDAA0B,OAMO;AAJnC,SAAgB,uBAAuB;IACrC,IAAA,sDAA8B,GAAE,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-typeorm3-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "NestJS utilities for TypeORM v0.3+",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,12 +38,14 @@
|
|
|
38
38
|
"libphonenumber-js": "^1.10.20",
|
|
39
39
|
"reflect-metadata": ">=0.1.13",
|
|
40
40
|
"rxjs": ">=7.2.0",
|
|
41
|
-
"typeorm": ">=0.3.0"
|
|
41
|
+
"typeorm": ">=0.3.0",
|
|
42
|
+
"typeorm-transactional": ">=0.5.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@nestjs/common": "^11.1.3",
|
|
45
46
|
"@nestjs/core": "^11.1.3",
|
|
46
47
|
"@nestjs/swagger": "^11.2.0",
|
|
48
|
+
"@nestjs/testing": "^11.1.3",
|
|
47
49
|
"@nestjs/typeorm": "^11.0.0",
|
|
48
50
|
"@types/jest": "^30.0.0",
|
|
49
51
|
"class-transformer": "^0.5.1",
|
|
@@ -55,6 +57,7 @@
|
|
|
55
57
|
"prettier": "^3.6.2",
|
|
56
58
|
"reflect-metadata": "^0.2.2",
|
|
57
59
|
"rimraf": "^6.0.1",
|
|
60
|
+
"rxjs": "^7.8.2",
|
|
58
61
|
"ts-jest": "^29.4.0",
|
|
59
62
|
"typedoc": "^0.28.6",
|
|
60
63
|
"typedoc-github-wiki-theme": "^2.1.0",
|