@wisemen/nestjs-typeorm 0.0.26 → 0.0.28
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/dist/extensions/repository.d.ts +5 -3
- package/dist/extensions/repository.js +60 -25
- package/dist/extensions/repository.js.map +1 -1
- package/dist/extensions/tests/repository-find-in-batches.test.d.ts +1 -0
- package/dist/extensions/tests/repository-find-in-batches.test.js +147 -0
- package/dist/extensions/tests/repository-find-in-batches.test.js.map +1 -0
- package/dist/extensions/tests/sql/datasource.d.ts +2 -0
- package/dist/extensions/tests/sql/datasource.js +16 -0
- package/dist/extensions/tests/sql/datasource.js.map +1 -0
- package/dist/extensions/tests/sql/entities/message.entity.d.ts +5 -0
- package/dist/extensions/tests/sql/entities/message.entity.js +32 -0
- package/dist/extensions/tests/sql/entities/message.entity.js.map +1 -0
- package/dist/extensions/tests/sql/entities/user.entity.d.ts +5 -0
- package/dist/extensions/tests/sql/entities/user.entity.js +32 -0
- package/dist/extensions/tests/sql/entities/user.entity.js.map +1 -0
- package/package.json +3 -2
|
@@ -3,7 +3,9 @@ export declare class TypeOrmRepository<T extends ObjectLiteral> extends Reposito
|
|
|
3
3
|
constructor(entity: EntityTarget<T>, manager: EntityManager);
|
|
4
4
|
findInBatches(options: FindOneOptions<T>, batchSize: number): AsyncGenerator<T[], void, void>;
|
|
5
5
|
findByInBatches(where: FindOptionsWhere<T> | FindOptionsWhere<T>[], batchSize: number): AsyncGenerator<T[], void, void>;
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
6
|
+
private addBatchingToOrder;
|
|
7
|
+
private addBatchingToWhere;
|
|
8
|
+
private addBatchingToSelect;
|
|
9
|
+
private addBatchConditionToWhereClause;
|
|
10
|
+
private getKeyCondition;
|
|
9
11
|
}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { MoreThan, Repository } from 'typeorm';
|
|
1
|
+
import { And, Equal, FindOperator, LessThan, MoreThan, Repository } from 'typeorm';
|
|
2
2
|
import { createTransactionManagerProxy } from './transaction.js';
|
|
3
3
|
export class TypeOrmRepository extends Repository {
|
|
4
4
|
constructor(entity, manager) {
|
|
5
5
|
super(entity, createTransactionManagerProxy(manager));
|
|
6
6
|
}
|
|
7
7
|
async *findInBatches(options, batchSize) {
|
|
8
|
-
|
|
9
|
-
throw new Error(`Entity ${this.metadata.name} has a composite primary key and cannot be fetched in batches`);
|
|
10
|
-
}
|
|
11
|
-
const primaryKey = this.metadata.primaryColumns[0].propertyName;
|
|
12
|
-
if (options.order !== undefined && primaryKey in options.order) {
|
|
13
|
-
throw new Error(`Cannot specify order for primary key "${this.metadata.name}.${primaryKey}" when fetching in batches`);
|
|
14
|
-
}
|
|
15
|
-
let lastPrimaryKeyValue = undefined;
|
|
8
|
+
const primaryKeys = this.metadata.primaryColumns.map(column => column.propertyName);
|
|
16
9
|
let entities = [];
|
|
10
|
+
let lastEntity = undefined;
|
|
17
11
|
do {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
12
|
+
const order = this.addBatchingToOrder(options.order, primaryKeys);
|
|
13
|
+
const select = this.addBatchingToSelect(options.select, order);
|
|
14
|
+
const where = this.addBatchingToWhere(options.where, order, lastEntity);
|
|
20
15
|
entities = await this.find({
|
|
21
16
|
...options,
|
|
17
|
+
select,
|
|
22
18
|
where,
|
|
23
19
|
order,
|
|
24
20
|
take: batchSize
|
|
@@ -26,32 +22,71 @@ export class TypeOrmRepository extends Repository {
|
|
|
26
22
|
if (entities.length === 0)
|
|
27
23
|
return;
|
|
28
24
|
yield entities;
|
|
29
|
-
|
|
30
|
-
} while (
|
|
25
|
+
lastEntity = entities.at(-1);
|
|
26
|
+
} while (entities.length === batchSize);
|
|
31
27
|
}
|
|
32
28
|
findByInBatches(where, batchSize) {
|
|
33
29
|
return this.findInBatches({ where }, batchSize);
|
|
34
30
|
}
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
addBatchingToOrder(order, keys) {
|
|
32
|
+
const batchOrder = Object.fromEntries(keys.map((key) => [key, order?.[key] ?? 'ASC']));
|
|
33
|
+
return {
|
|
34
|
+
...order,
|
|
35
|
+
...batchOrder
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
addBatchingToWhere(where, order, lastEntity) {
|
|
39
|
+
if (lastEntity === undefined) {
|
|
37
40
|
return where;
|
|
38
41
|
}
|
|
39
42
|
if (Array.isArray(where)) {
|
|
40
|
-
return where.
|
|
43
|
+
return where.flatMap(whereClause => this.addBatchConditionToWhereClause(whereClause, order, lastEntity));
|
|
41
44
|
}
|
|
42
|
-
return this.
|
|
45
|
+
return this.addBatchConditionToWhereClause(where, order, lastEntity);
|
|
43
46
|
}
|
|
44
|
-
|
|
47
|
+
addBatchingToSelect(select, order) {
|
|
48
|
+
if (select === undefined) {
|
|
49
|
+
return select;
|
|
50
|
+
}
|
|
51
|
+
const keys = Object.keys(order);
|
|
52
|
+
if (Array.isArray(select)) {
|
|
53
|
+
return [...new Set([...select, ...keys])];
|
|
54
|
+
}
|
|
45
55
|
return {
|
|
46
|
-
...
|
|
47
|
-
[key]
|
|
56
|
+
...select,
|
|
57
|
+
...Object.fromEntries(keys.map(key => [key, true]))
|
|
48
58
|
};
|
|
49
59
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
addBatchConditionToWhereClause(where, order, lastEntity) {
|
|
61
|
+
const clauses = [];
|
|
62
|
+
const keys = Object.keys(order);
|
|
63
|
+
for (let i = keys.length - 1; i >= 0; i--) {
|
|
64
|
+
const key = keys[i];
|
|
65
|
+
const keyLastValue = lastEntity[key];
|
|
66
|
+
const preceedingKeys = keys.slice(0, i);
|
|
67
|
+
const preceedingKeysLastValues = preceedingKeys.map(k => lastEntity[k]);
|
|
68
|
+
const preceedingKeysWhere = Object.fromEntries(preceedingKeys.map((k, i) => [k, preceedingKeysLastValues[i]]));
|
|
69
|
+
const clause = {
|
|
70
|
+
...where,
|
|
71
|
+
...preceedingKeysWhere,
|
|
72
|
+
[key]: this.getKeyCondition(where, order, key, keyLastValue)
|
|
73
|
+
};
|
|
74
|
+
clauses.push(clause);
|
|
75
|
+
}
|
|
76
|
+
return clauses;
|
|
77
|
+
}
|
|
78
|
+
getKeyCondition(where, order, key, lastKeyValue) {
|
|
79
|
+
const existingCondition = where?.[key];
|
|
80
|
+
const batchCondition = order?.[key] === 'ASC' ? MoreThan(lastKeyValue) : LessThan(lastKeyValue);
|
|
81
|
+
if (existingCondition === undefined) {
|
|
82
|
+
return batchCondition;
|
|
83
|
+
}
|
|
84
|
+
else if (existingCondition instanceof FindOperator) {
|
|
85
|
+
return And(batchCondition, existingCondition);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return And(batchCondition, Equal(existingCondition));
|
|
89
|
+
}
|
|
55
90
|
}
|
|
56
91
|
}
|
|
57
92
|
//# sourceMappingURL=repository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../lib/extensions/repository.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../lib/extensions/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAyC,KAAK,EAAkB,YAAY,EAAoF,QAAQ,EAAE,QAAQ,EAAiB,UAAU,EAAE,MAAM,SAAS,CAAA;AAC1O,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAA;AAEhE,MAAM,OAAO,iBAA2C,SAAQ,UAAc;IAC5E,YAAa,MAAuB,EAAE,OAAsB;QAC1D,KAAK,CAAC,MAAM,EAAE,6BAA6B,CAAC,OAAO,CAAC,CAAC,CAAA;IACvD,CAAC;IAED,KAAK,CAAA,CAAE,aAAa,CAClB,OAA0B,EAC1B,SAAiB;QAEjB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE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AAM,CAAC;YACN,OAAO,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { after, before, describe, it } from "node:test";
|
|
2
|
+
import { expect } from 'expect';
|
|
3
|
+
import { dataSource } from "./sql/datasource.js";
|
|
4
|
+
import { UserEntity } from "./sql/entities/user.entity.js";
|
|
5
|
+
import { TypeOrmRepository } from "../repository.js";
|
|
6
|
+
import { LessThan } from "typeorm";
|
|
7
|
+
import { MessageEntity } from "./sql/entities/message.entity.js";
|
|
8
|
+
describe('Repository find in batches test', () => {
|
|
9
|
+
before(async () => {
|
|
10
|
+
await dataSource.initialize();
|
|
11
|
+
await dataSource.synchronize(true);
|
|
12
|
+
});
|
|
13
|
+
after(async () => {
|
|
14
|
+
await dataSource.destroy();
|
|
15
|
+
});
|
|
16
|
+
describe('Batching with filter and sorting on at most 1 field', () => {
|
|
17
|
+
let repository;
|
|
18
|
+
before(async () => {
|
|
19
|
+
repository = new TypeOrmRepository(UserEntity, dataSource.manager);
|
|
20
|
+
await repository.insert([
|
|
21
|
+
{ id: 1, name: "Alice", age: 25 },
|
|
22
|
+
{ id: 2, name: "Bob", age: 30 },
|
|
23
|
+
{ id: 3, name: "Charlie", age: 28 },
|
|
24
|
+
{ id: 4, name: "Diana", age: 22 },
|
|
25
|
+
{ id: 5, name: "Eve", age: 35 }
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
28
|
+
it('finds in batches without filters or sorting', async () => {
|
|
29
|
+
const result = repository.findInBatches({}, 2);
|
|
30
|
+
let batches = [];
|
|
31
|
+
for await (const batch of result) {
|
|
32
|
+
batches.push(batch);
|
|
33
|
+
}
|
|
34
|
+
expect(batches).toHaveLength(3);
|
|
35
|
+
expect(batches[0]).toHaveLength(2);
|
|
36
|
+
expect(batches[1]).toHaveLength(2);
|
|
37
|
+
expect(batches[2]).toHaveLength(1);
|
|
38
|
+
expect(batches[0][0].name).toBe("Alice");
|
|
39
|
+
expect(batches[0][1].name).toBe("Bob");
|
|
40
|
+
expect(batches[1][0].name).toBe("Charlie");
|
|
41
|
+
expect(batches[1][1].name).toBe("Diana");
|
|
42
|
+
expect(batches[2][0].name).toBe("Eve");
|
|
43
|
+
});
|
|
44
|
+
it('finds in batches without filters with sorting', async () => {
|
|
45
|
+
const result = repository.findInBatches({
|
|
46
|
+
order: { name: 'DESC' }
|
|
47
|
+
}, 2);
|
|
48
|
+
let batches = [];
|
|
49
|
+
for await (const batch of result) {
|
|
50
|
+
batches.push(batch);
|
|
51
|
+
}
|
|
52
|
+
expect(batches).toHaveLength(3);
|
|
53
|
+
expect(batches[0]).toHaveLength(2);
|
|
54
|
+
expect(batches[1]).toHaveLength(2);
|
|
55
|
+
expect(batches[2]).toHaveLength(1);
|
|
56
|
+
expect(batches[0][0].name).toBe("Eve");
|
|
57
|
+
expect(batches[0][1].name).toBe("Diana");
|
|
58
|
+
expect(batches[1][0].name).toBe("Charlie");
|
|
59
|
+
expect(batches[1][1].name).toBe("Bob");
|
|
60
|
+
expect(batches[2][0].name).toBe("Alice");
|
|
61
|
+
});
|
|
62
|
+
it('finds in batches with filters without sorting', async () => {
|
|
63
|
+
const result = repository.findInBatches({
|
|
64
|
+
where: { age: LessThan(30) }
|
|
65
|
+
}, 2);
|
|
66
|
+
let batches = [];
|
|
67
|
+
for await (const batch of result) {
|
|
68
|
+
batches.push(batch);
|
|
69
|
+
}
|
|
70
|
+
expect(batches).toHaveLength(2);
|
|
71
|
+
expect(batches[0]).toHaveLength(2);
|
|
72
|
+
expect(batches[1]).toHaveLength(1);
|
|
73
|
+
expect(batches[0][0].name).toBe('Alice');
|
|
74
|
+
expect(batches[0][1].name).toBe('Charlie');
|
|
75
|
+
expect(batches[1][0].name).toBe('Diana');
|
|
76
|
+
});
|
|
77
|
+
it('finds in batches with filters with sorting', async () => {
|
|
78
|
+
const result = repository.findInBatches({
|
|
79
|
+
where: { age: LessThan(30) },
|
|
80
|
+
order: { age: 'ASC' }
|
|
81
|
+
}, 2);
|
|
82
|
+
let batches = [];
|
|
83
|
+
for await (const batch of result) {
|
|
84
|
+
batches.push(batch);
|
|
85
|
+
}
|
|
86
|
+
expect(batches).toHaveLength(2);
|
|
87
|
+
expect(batches[0]).toHaveLength(2);
|
|
88
|
+
expect(batches[1]).toHaveLength(1);
|
|
89
|
+
expect(batches[0][0].name).toBe('Diana');
|
|
90
|
+
expect(batches[0][1].name).toBe('Alice');
|
|
91
|
+
expect(batches[1][0].name).toBe('Charlie');
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('Batching with filter and sorting on multiple fields', () => {
|
|
95
|
+
let repository;
|
|
96
|
+
before(async () => {
|
|
97
|
+
repository = new TypeOrmRepository(MessageEntity, dataSource.manager);
|
|
98
|
+
const now = new Date();
|
|
99
|
+
const past = new Date(now.getTime() - 1000);
|
|
100
|
+
const future = new Date(now.getTime() + 1000);
|
|
101
|
+
await repository.insert([
|
|
102
|
+
{ id: 1, createdAt: now, message: "Message 1" },
|
|
103
|
+
{ id: 2, createdAt: past, message: "Message 2" },
|
|
104
|
+
{ id: 3, createdAt: future, message: "Message 3" },
|
|
105
|
+
{ id: 4, createdAt: now, message: "Message 4" },
|
|
106
|
+
{ id: 5, createdAt: past, message: "Message 5" }
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
109
|
+
it('finds in batches with implicit secondary sorting', async () => {
|
|
110
|
+
const result = repository.findInBatches({
|
|
111
|
+
order: { createdAt: 'DESC' }
|
|
112
|
+
}, 2);
|
|
113
|
+
let batches = [];
|
|
114
|
+
for await (const batch of result) {
|
|
115
|
+
batches.push(batch);
|
|
116
|
+
}
|
|
117
|
+
expect(batches).toHaveLength(3);
|
|
118
|
+
expect(batches[0]).toHaveLength(2);
|
|
119
|
+
expect(batches[1]).toHaveLength(2);
|
|
120
|
+
expect(batches[2]).toHaveLength(1);
|
|
121
|
+
expect(batches[0][0].id).toBe(3);
|
|
122
|
+
expect(batches[0][1].id).toBe(1);
|
|
123
|
+
expect(batches[1][0].id).toBe(4);
|
|
124
|
+
expect(batches[1][1].id).toBe(2);
|
|
125
|
+
expect(batches[2][0].id).toBe(5);
|
|
126
|
+
});
|
|
127
|
+
it('finds in batches with explicit secondary sorting', async () => {
|
|
128
|
+
const result = repository.findInBatches({
|
|
129
|
+
order: { createdAt: 'DESC', id: 'DESC' }
|
|
130
|
+
}, 2);
|
|
131
|
+
let batches = [];
|
|
132
|
+
for await (const batch of result) {
|
|
133
|
+
batches.push(batch);
|
|
134
|
+
}
|
|
135
|
+
expect(batches).toHaveLength(3);
|
|
136
|
+
expect(batches[0]).toHaveLength(2);
|
|
137
|
+
expect(batches[1]).toHaveLength(2);
|
|
138
|
+
expect(batches[2]).toHaveLength(1);
|
|
139
|
+
expect(batches[0][0].id).toBe(3);
|
|
140
|
+
expect(batches[0][1].id).toBe(4);
|
|
141
|
+
expect(batches[1][0].id).toBe(1);
|
|
142
|
+
expect(batches[1][1].id).toBe(5);
|
|
143
|
+
expect(batches[2][0].id).toBe(2);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=repository-find-in-batches.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-find-in-batches.test.js","sourceRoot":"","sources":["../../../lib/extensions/tests/repository-find-in-batches.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OA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AAC,CAAC,CAAC,CAAA;YAChC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAChC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAChC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAClC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataSource } from "typeorm";
|
|
2
|
+
import { SnakeNamingStrategy } from "../../../naming/snake-case.naming-strategy.js";
|
|
3
|
+
import { sslHelper } from "../../../helpers/ssl.js";
|
|
4
|
+
export const dataSource = new DataSource({
|
|
5
|
+
name: 'default',
|
|
6
|
+
type: 'postgres',
|
|
7
|
+
url: process.env.DATABASE_URI,
|
|
8
|
+
ssl: sslHelper(process.env.DATABASE_SSL),
|
|
9
|
+
extra: { max: 50 },
|
|
10
|
+
logging: false,
|
|
11
|
+
synchronize: false,
|
|
12
|
+
migrationsRun: true,
|
|
13
|
+
entities: ['dist/**/*.entity.js'],
|
|
14
|
+
namingStrategy: new SnakeNamingStrategy()
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=datasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../../../lib/extensions/tests/sql/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;IACvC,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;IAC7B,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACxC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IAClB,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IACjC,cAAc,EAAE,IAAI,mBAAmB,EAAE;CAC1C,CAAC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
|
11
|
+
let MessageEntity = class MessageEntity {
|
|
12
|
+
id;
|
|
13
|
+
createdAt;
|
|
14
|
+
message;
|
|
15
|
+
};
|
|
16
|
+
__decorate([
|
|
17
|
+
PrimaryGeneratedColumn(),
|
|
18
|
+
__metadata("design:type", Number)
|
|
19
|
+
], MessageEntity.prototype, "id", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
Column({ type: 'timestamp' }),
|
|
22
|
+
__metadata("design:type", Date)
|
|
23
|
+
], MessageEntity.prototype, "createdAt", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
Column({ type: 'varchar' }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], MessageEntity.prototype, "message", void 0);
|
|
28
|
+
MessageEntity = __decorate([
|
|
29
|
+
Entity()
|
|
30
|
+
], MessageEntity);
|
|
31
|
+
export { MessageEntity };
|
|
32
|
+
//# sourceMappingURL=message.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.entity.js","sourceRoot":"","sources":["../../../../../lib/extensions/tests/sql/entities/message.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAG1D,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,EAAE,CAAQ;IAGV,SAAS,CAAM;IAGf,OAAO,CAAQ;CAChB,CAAA;AAPC;IADC,sBAAsB,EAAE;;yCACf;AAGV;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;8BACnB,IAAI;gDAAA;AAGf;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;8CACb;AARJ,aAAa;IADzB,MAAM,EAAE;GACI,aAAa,CASzB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
|
11
|
+
let UserEntity = class UserEntity {
|
|
12
|
+
id;
|
|
13
|
+
name;
|
|
14
|
+
age;
|
|
15
|
+
};
|
|
16
|
+
__decorate([
|
|
17
|
+
PrimaryGeneratedColumn(),
|
|
18
|
+
__metadata("design:type", Number)
|
|
19
|
+
], UserEntity.prototype, "id", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
Column({ type: 'varchar' }),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], UserEntity.prototype, "name", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
Column({ type: 'int' }),
|
|
26
|
+
__metadata("design:type", Number)
|
|
27
|
+
], UserEntity.prototype, "age", void 0);
|
|
28
|
+
UserEntity = __decorate([
|
|
29
|
+
Entity()
|
|
30
|
+
], UserEntity);
|
|
31
|
+
export { UserEntity };
|
|
32
|
+
//# sourceMappingURL=user.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../../../lib/extensions/tests/sql/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAG1D,IAAM,UAAU,GAAhB,MAAM,UAAU;IAErB,EAAE,CAAQ;IAGV,IAAI,CAAQ;IAGZ,GAAG,CAAQ;CACZ,CAAA;AAPC;IADC,sBAAsB,EAAE;;sCACf;AAGV;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;wCAChB;AAGZ;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;uCACb;AARA,UAAU;IADtB,MAAM,EAAE;GACI,UAAU,CAStB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wisemen/nestjs-typeorm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
"clean": "rm -rf ./dist",
|
|
14
14
|
"build": "tsc",
|
|
15
15
|
"pretest": "npm run clean && npm run build",
|
|
16
|
-
"test": "node --test",
|
|
16
|
+
"test": "node --env-file=.env --test",
|
|
17
17
|
"prerelease": "npm run build",
|
|
18
18
|
"release": "pnpx release-it"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^24.3.0",
|
|
22
22
|
"eslint": "^9.33.0",
|
|
23
|
+
"expect": "^30.0.5",
|
|
23
24
|
"typescript": "^5.9.2"
|
|
24
25
|
},
|
|
25
26
|
"author": "Joren Vandeweyer",
|