@wisemen/nestjs-typeorm 0.0.27 → 0.0.29
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 +3 -0
- package/dist/extensions/repository.js +43 -16
- package/dist/extensions/repository.js.map +1 -1
- package/dist/extensions/tests/repository-find-in-batches.test.js +148 -75
- package/dist/extensions/tests/repository-find-in-batches.test.js.map +1 -1
- 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/{test.entity.js → sql/entities/user.entity.js} +1 -1
- package/dist/extensions/tests/sql/entities/user.entity.js.map +1 -0
- package/package.json +1 -1
- package/dist/extensions/tests/test.entity.js.map +0 -1
- /package/dist/extensions/tests/{test.entity.d.ts → sql/entities/user.entity.d.ts} +0 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type EntityManager, type EntityTarget, FindOneOptions, FindOptionsWhere, ObjectLiteral, Repository } from 'typeorm';
|
|
2
2
|
export declare class TypeOrmRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
3
3
|
constructor(entity: EntityTarget<T>, manager: EntityManager);
|
|
4
|
+
findNextBatch(options: FindOneOptions<T>, batchSize: number, lastEntity: Partial<T> | undefined): Promise<T[]>;
|
|
4
5
|
findInBatches(options: FindOneOptions<T>, batchSize: number): AsyncGenerator<T[], void, void>;
|
|
5
6
|
findByInBatches(where: FindOptionsWhere<T> | FindOptionsWhere<T>[], batchSize: number): AsyncGenerator<T[], void, void>;
|
|
6
7
|
private addBatchingToOrder;
|
|
8
|
+
private addBatchingToSelect;
|
|
7
9
|
private addBatchingToWhere;
|
|
8
10
|
private addBatchConditionToWhereClause;
|
|
11
|
+
private getLastEntityEntriesForOrder;
|
|
9
12
|
private getKeyCondition;
|
|
10
13
|
}
|
|
@@ -4,19 +4,24 @@ export class TypeOrmRepository extends Repository {
|
|
|
4
4
|
constructor(entity, manager) {
|
|
5
5
|
super(entity, createTransactionManagerProxy(manager));
|
|
6
6
|
}
|
|
7
|
-
async
|
|
7
|
+
async findNextBatch(options, batchSize, lastEntity) {
|
|
8
8
|
const primaryKeys = this.metadata.primaryColumns.map(column => column.propertyName);
|
|
9
|
+
const order = this.addBatchingToOrder(options.order, primaryKeys);
|
|
10
|
+
const select = this.addBatchingToSelect(options.select, order);
|
|
11
|
+
const where = this.addBatchingToWhere(options.where, order, lastEntity);
|
|
12
|
+
return await this.find({
|
|
13
|
+
...options,
|
|
14
|
+
select,
|
|
15
|
+
where,
|
|
16
|
+
order,
|
|
17
|
+
take: batchSize
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async *findInBatches(options, batchSize) {
|
|
9
21
|
let entities = [];
|
|
10
22
|
let lastEntity = undefined;
|
|
11
23
|
do {
|
|
12
|
-
|
|
13
|
-
const where = this.addBatchingToWhere(options.where, order, lastEntity);
|
|
14
|
-
entities = await this.find({
|
|
15
|
-
...options,
|
|
16
|
-
where,
|
|
17
|
-
order,
|
|
18
|
-
take: batchSize
|
|
19
|
-
});
|
|
24
|
+
entities = await this.findNextBatch(options, batchSize, lastEntity);
|
|
20
25
|
if (entities.length === 0)
|
|
21
26
|
return;
|
|
22
27
|
yield entities;
|
|
@@ -33,6 +38,19 @@ export class TypeOrmRepository extends Repository {
|
|
|
33
38
|
...batchOrder
|
|
34
39
|
};
|
|
35
40
|
}
|
|
41
|
+
addBatchingToSelect(select, order) {
|
|
42
|
+
if (select === undefined) {
|
|
43
|
+
return select;
|
|
44
|
+
}
|
|
45
|
+
const keys = Object.keys(order);
|
|
46
|
+
if (Array.isArray(select)) {
|
|
47
|
+
return [...new Set([...select, ...keys])];
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
...select,
|
|
51
|
+
...Object.fromEntries(keys.map(key => [key, true]))
|
|
52
|
+
};
|
|
53
|
+
}
|
|
36
54
|
addBatchingToWhere(where, order, lastEntity) {
|
|
37
55
|
if (lastEntity === undefined) {
|
|
38
56
|
return where;
|
|
@@ -43,26 +61,35 @@ export class TypeOrmRepository extends Repository {
|
|
|
43
61
|
return this.addBatchConditionToWhereClause(where, order, lastEntity);
|
|
44
62
|
}
|
|
45
63
|
addBatchConditionToWhereClause(where, order, lastEntity) {
|
|
64
|
+
const [keys, keysLastEntityValues] = this.getLastEntityEntriesForOrder(order, lastEntity);
|
|
46
65
|
const clauses = [];
|
|
47
|
-
const keys = Object.keys(order);
|
|
48
66
|
for (let i = keys.length - 1; i >= 0; i--) {
|
|
49
67
|
const key = keys[i];
|
|
50
|
-
const
|
|
68
|
+
const keyLastEntityValue = keysLastEntityValues[i];
|
|
51
69
|
const preceedingKeys = keys.slice(0, i);
|
|
52
|
-
const
|
|
53
|
-
const preceedingKeysWhere = Object.fromEntries(preceedingKeys.map((k, i) => [k,
|
|
70
|
+
const preceedingKeysLastEntityValues = keysLastEntityValues.slice(0, i);
|
|
71
|
+
const preceedingKeysWhere = Object.fromEntries(preceedingKeys.map((k, i) => [k, preceedingKeysLastEntityValues[i]]));
|
|
54
72
|
const clause = {
|
|
55
73
|
...where,
|
|
56
74
|
...preceedingKeysWhere,
|
|
57
|
-
[key]: this.getKeyCondition(where, order, key,
|
|
75
|
+
[key]: this.getKeyCondition(where, order, key, keyLastEntityValue)
|
|
58
76
|
};
|
|
59
77
|
clauses.push(clause);
|
|
60
78
|
}
|
|
61
79
|
return clauses;
|
|
62
80
|
}
|
|
63
|
-
|
|
81
|
+
getLastEntityEntriesForOrder(order, lastEntity) {
|
|
82
|
+
const keys = Object.keys(order);
|
|
83
|
+
const entityKeys = Object.keys(lastEntity);
|
|
84
|
+
if (!keys.every(key => entityKeys.includes(key))) {
|
|
85
|
+
throw new Error(`entity must include at least following properties: ${keys.join(', ')}`);
|
|
86
|
+
}
|
|
87
|
+
const keysValues = keys.map(key => lastEntity[key]);
|
|
88
|
+
return [keys, keysValues];
|
|
89
|
+
}
|
|
90
|
+
getKeyCondition(where, order, key, keyLastEntityValue) {
|
|
64
91
|
const existingCondition = where?.[key];
|
|
65
|
-
const batchCondition = order?.[key] === 'ASC' ? MoreThan(
|
|
92
|
+
const batchCondition = order?.[key] === 'ASC' ? MoreThan(keyLastEntityValue) : LessThan(keyLastEntityValue);
|
|
66
93
|
if (existingCondition === undefined) {
|
|
67
94
|
return batchCondition;
|
|
68
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../lib/extensions/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAyC,KAAK,EAAkB,YAAY,
|
|
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,CAAC,aAAa,CACjB,OAA0B,EAC1B,SAAiB,EACjB,UAAkC;QAElC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;QACnF,MAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QAC9D,MAAM,KAAK,GAAG,IAAI,CA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3B,CAAC;IAEO,eAAe,CACrB,KAAsC,EACtC,KAAsC,EACtC,GAAW,EACX,kBAA2B;QAE3B,MAAM,iBAAiB,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;QACtC,MAAM,cAAc,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAA;QAE3G,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACpC,OAAO,cAAc,CAAA;QACvB,CAAC;aAAM,IAAI,iBAAiB,YAAY,YAAY,EAAE,CAAC;YACrD,OAAO,GAAG,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;QAC/C,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,90 +1,163 @@
|
|
|
1
1
|
import { after, before, describe, it } from "node:test";
|
|
2
2
|
import { expect } from 'expect';
|
|
3
3
|
import { dataSource } from "./sql/datasource.js";
|
|
4
|
-
import { UserEntity } from "./
|
|
4
|
+
import { UserEntity } from "./sql/entities/user.entity.js";
|
|
5
5
|
import { TypeOrmRepository } from "../repository.js";
|
|
6
|
-
import { LessThan } from "typeorm";
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { LessThan, MoreThanOrEqual } from "typeorm";
|
|
7
|
+
import { MessageEntity } from "./sql/entities/message.entity.js";
|
|
8
|
+
describe('Repository find in batches test', () => {
|
|
9
9
|
before(async () => {
|
|
10
10
|
await dataSource.initialize();
|
|
11
11
|
await dataSource.synchronize(true);
|
|
12
|
-
repository = new TypeOrmRepository(UserEntity, dataSource.manager);
|
|
13
|
-
await repository.insert([
|
|
14
|
-
{ id: 1, name: "Alice", age: 25 },
|
|
15
|
-
{ id: 2, name: "Bob", age: 30 },
|
|
16
|
-
{ id: 3, name: "Charlie", age: 28 },
|
|
17
|
-
{ id: 4, name: "Diana", age: 22 },
|
|
18
|
-
{ id: 5, name: "Eve", age: 35 }
|
|
19
|
-
]);
|
|
20
12
|
});
|
|
21
13
|
after(async () => {
|
|
22
14
|
await dataSource.destroy();
|
|
23
15
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
it('finds in batches with disjunction filters with sorting', async () => {
|
|
94
|
+
const result = repository.findInBatches({
|
|
95
|
+
where: [{ age: LessThan(25) }, { age: MoreThanOrEqual(30) }],
|
|
96
|
+
order: { age: 'DESC' }
|
|
97
|
+
}, 2);
|
|
98
|
+
let batches = [];
|
|
99
|
+
for await (const batch of result) {
|
|
100
|
+
batches.push(batch);
|
|
101
|
+
}
|
|
102
|
+
expect(batches).toHaveLength(2);
|
|
103
|
+
expect(batches[0]).toHaveLength(2);
|
|
104
|
+
expect(batches[1]).toHaveLength(1);
|
|
105
|
+
expect(batches[0][0].name).toBe('Eve');
|
|
106
|
+
expect(batches[0][1].name).toBe('Bob');
|
|
107
|
+
expect(batches[1][0].name).toBe('Diana');
|
|
108
|
+
});
|
|
39
109
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
batches.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
110
|
+
describe('Batching with filter and sorting on multiple fields', () => {
|
|
111
|
+
let repository;
|
|
112
|
+
before(async () => {
|
|
113
|
+
repository = new TypeOrmRepository(MessageEntity, dataSource.manager);
|
|
114
|
+
const now = new Date();
|
|
115
|
+
const past = new Date(now.getTime() - 1000);
|
|
116
|
+
const future = new Date(now.getTime() + 1000);
|
|
117
|
+
await repository.insert([
|
|
118
|
+
{ id: 1, createdAt: now, message: "Message 1" },
|
|
119
|
+
{ id: 2, createdAt: past, message: "Message 2" },
|
|
120
|
+
{ id: 3, createdAt: future, message: "Message 3" },
|
|
121
|
+
{ id: 4, createdAt: now, message: "Message 4" },
|
|
122
|
+
{ id: 5, createdAt: past, message: "Message 5" }
|
|
123
|
+
]);
|
|
124
|
+
});
|
|
125
|
+
it('finds in batches with implicit secondary sorting', async () => {
|
|
126
|
+
const result = repository.findInBatches({
|
|
127
|
+
order: { createdAt: 'DESC' }
|
|
128
|
+
}, 2);
|
|
129
|
+
let batches = [];
|
|
130
|
+
for await (const batch of result) {
|
|
131
|
+
batches.push(batch);
|
|
132
|
+
}
|
|
133
|
+
expect(batches).toHaveLength(3);
|
|
134
|
+
expect(batches[0]).toHaveLength(2);
|
|
135
|
+
expect(batches[1]).toHaveLength(2);
|
|
136
|
+
expect(batches[2]).toHaveLength(1);
|
|
137
|
+
expect(batches[0][0].id).toBe(3);
|
|
138
|
+
expect(batches[0][1].id).toBe(1);
|
|
139
|
+
expect(batches[1][0].id).toBe(4);
|
|
140
|
+
expect(batches[1][1].id).toBe(2);
|
|
141
|
+
expect(batches[2][0].id).toBe(5);
|
|
142
|
+
});
|
|
143
|
+
it('finds in batches with explicit secondary sorting', async () => {
|
|
144
|
+
const result = repository.findInBatches({
|
|
145
|
+
order: { createdAt: 'DESC', id: 'DESC' }
|
|
146
|
+
}, 2);
|
|
147
|
+
let batches = [];
|
|
148
|
+
for await (const batch of result) {
|
|
149
|
+
batches.push(batch);
|
|
150
|
+
}
|
|
151
|
+
expect(batches).toHaveLength(3);
|
|
152
|
+
expect(batches[0]).toHaveLength(2);
|
|
153
|
+
expect(batches[1]).toHaveLength(2);
|
|
154
|
+
expect(batches[2]).toHaveLength(1);
|
|
155
|
+
expect(batches[0][0].id).toBe(3);
|
|
156
|
+
expect(batches[0][1].id).toBe(4);
|
|
157
|
+
expect(batches[1][0].id).toBe(1);
|
|
158
|
+
expect(batches[1][1].id).toBe(5);
|
|
159
|
+
expect(batches[2][0].id).toBe(2);
|
|
160
|
+
});
|
|
88
161
|
});
|
|
89
162
|
});
|
|
90
163
|
//# sourceMappingURL=repository-find-in-batches.test.js.map
|
|
@@ -1 +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,
|
|
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,OAAO,EAAE,QAAQ,EAAY,eAAe,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,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,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,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 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.entity.js","sourceRoot":"","sources":["../../../lib/extensions/tests/test.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"}
|
|
File without changes
|