typeorm-extensions 1.2.0 → 1.2.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/README.md +11 -5
- package/package.json +1 -1
- package/src/constants/index.ts +2 -2
package/README.md
CHANGED
|
@@ -25,20 +25,26 @@ npm install typeorm-extensions
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import { createQueryBuilder } from 'typeorm';
|
|
29
28
|
import 'typeorm-extensions'; // Import the library root to extend the QueryBuilder with all extensions
|
|
30
29
|
|
|
31
30
|
// Or init specific extension: import from 'typeorm-extensions/dist/extensions/pagination.extension';
|
|
32
31
|
|
|
33
|
-
const query =
|
|
34
|
-
.
|
|
32
|
+
const query = myDataSource
|
|
33
|
+
.createQueryBuilder()
|
|
34
|
+
.from(UserEntity, 'users')
|
|
35
|
+
// Join relation defined in entity model
|
|
36
|
+
.leftJoinTyped(user => users.profile, 'profile')
|
|
37
|
+
// Select type-safe properties
|
|
35
38
|
.selectTyped(user => ([
|
|
36
39
|
id: user.id,
|
|
37
40
|
name: user.name,
|
|
38
41
|
email: user.email,
|
|
39
42
|
]))
|
|
40
|
-
.
|
|
41
|
-
|
|
43
|
+
.whereTyped(user => user.name, 'ILIKE :search', { search: 'John' })
|
|
44
|
+
// Order by type-safe own and relation properties
|
|
45
|
+
.orderByTyped(user => user.profile.avatarUrl, 'ASC', 'NULLS LAST')
|
|
46
|
+
// Use pagination as simple as that
|
|
47
|
+
.applyPaginationFilter({ page: 1, pageSize: 10 }, { useTakeAndSkip: true });
|
|
42
48
|
```
|
|
43
49
|
|
|
44
50
|
## Documentation
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const defaultPageSize = 10;
|
|
2
2
|
|
|
3
|
-
export const defaultUseTakeAndSkip =
|
|
3
|
+
export const defaultUseTakeAndSkip = false;
|
|
4
4
|
|
|
5
|
-
export const defaultUseDoubleQuotes =
|
|
5
|
+
export const defaultUseDoubleQuotes = true;
|
|
6
6
|
|
|
7
7
|
export const defaultOrderDirection = 'ASC';
|
|
8
8
|
|