@sqb/nestjs 5.0.6 → 6.0.0

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.
Files changed (2) hide show
  1. package/README.md +62 -31
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -6,30 +6,69 @@
6
6
 
7
7
  [![NPM Version][npm-image]][npm-url]
8
8
  [![NPM Downloads][downloads-image]][downloads-url]
9
- [![Build Status][travis-image]][travis-url]
9
+ [![CI Tests][ci-test-image]][ci-test-url]
10
10
  [![Test Coverage][coveralls-image]][coveralls-url]
11
- [![Dependencies][dependencies-image]][dependencies-url]
12
- [![DevDependencies][devdependencies-image]][devdependencies-url]
13
- [![Package Quality][quality-image]][quality-url]
14
11
 
15
12
  ## About SQB
16
13
 
17
14
  SQB is an extensible, multi-dialect SQL query builder and Database connection wrapper for NodeJS.
18
15
 
19
- ## Main goals
16
+ ## About @sqb/nestjs
17
+
18
+ `@sqb/nestjs` wires an [`@sqb/connect`](../connect) `SqbClient` into a NestJS application as an
19
+ injectable, application-scoped provider. `SqbModule.forRoot()` accepts connection options directly
20
+ (or falls back to `SQB_*` environment variables — see below), while `SqbModule.forRootAsync()`
21
+ resolves them from a factory, e.g. NestJS's `ConfigService`. Either way, the module opens the
22
+ connection on `onApplicationBootstrap` and closes it gracefully on `onApplicationShutdown`.
23
+
24
+ ```ts
25
+ import { Module } from '@nestjs/common';
26
+ import { SqbModule } from '@sqb/nestjs';
27
+
28
+ @Module({
29
+ imports: [
30
+ SqbModule.forRoot({
31
+ useValue: {
32
+ dialect: 'postgres',
33
+ host: 'localhost',
34
+ database: 'mydb',
35
+ },
36
+ }),
37
+ ],
38
+ })
39
+ export class AppModule {}
40
+ ```
41
+
42
+ The client is provided under the `SqbClient` token by default (override it with `token` in the
43
+ module options if you need to register more than one connection), so it can be injected like any
44
+ other NestJS provider:
20
45
 
21
- - Single code base for any sql based database
22
- - Powerful and simplified query coding scheme
23
- - Fast applications with low memory requirements
24
- - Let applications work with large data tables efficiently
25
- - Support latest JavaScript language standards
26
- - Lightweight and extensible framework.
46
+ ```ts
47
+ import { Injectable } from '@nestjs/common';
48
+ import { SqbClient } from '@sqb/connect';
27
49
 
28
- You can report bugs and discuss features on the [GitHub issues](https://github.com/sqbjs/sqb/issues) page
50
+ @Injectable()
51
+ export class UsersService {
52
+ constructor(private readonly client: SqbClient) {}
29
53
 
30
- Thanks to all of the great [contributions](https://github.com/sqbjs/sqb/graphs/contributors) to the project.
54
+ findAll() {
55
+ return this.client.getRepository('User').findMany();
56
+ }
57
+ }
58
+ ```
31
59
 
32
- You may want to check detailed [DOCUMENTATION](https://sqbjs.github.io/sqb/)
60
+ For async, factory-based configuration:
61
+
62
+ ```ts
63
+ SqbModule.forRootAsync({
64
+ inject: [ConfigService],
65
+ useFactory: (config: ConfigService) => ({
66
+ dialect: 'postgres',
67
+ host: config.get('DB_HOST'),
68
+ database: config.get('DB_NAME'),
69
+ }),
70
+ });
71
+ ```
33
72
 
34
73
  ## Installation
35
74
 
@@ -39,7 +78,7 @@ $ npm install @sqb/nestjs --save
39
78
 
40
79
  ## Node Compatibility
41
80
 
42
- - node >= 16.x
81
+ - node >= 20.x
43
82
 
44
83
  ## Environment Variables
45
84
 
@@ -49,7 +88,7 @@ All environment variables starts with prefix (SQB\_). This can be configured whi
49
88
  <!--- BEGIN env --->
50
89
 
51
90
  | Environment Variable | Type | Default | Description |
52
- | ---------------------------- | ------- | ------- | ----------------------------------------------------- |
91
+ | ----------------------------- | ------- | ------- | ----------------------------------------------------- |
53
92
  | SQB_DIALECT | String | | Database dialect (e.g. postgres, mysql, oracle) |
54
93
  | SQB_CONNECTION_NAME | String | | Logical name of the database connection |
55
94
  | SQB_HOST | String | | Database server host address |
@@ -66,9 +105,9 @@ All environment variables starts with prefix (SQB\_). This can be configured whi
66
105
  | SQB_POOL_ACQUIRE_MAX_RETRIES | Number | | Maximum number of retries when acquiring a connection |
67
106
  | SQB_POOL_ACQUIRE_RETRY_WAIT | Number | | Wait time (ms) between acquire retry attempts |
68
107
  | SQB_POOL_FIFO | Boolean | | Whether the pool queue operates in FIFO mode |
69
- | SQB_POOL_MAX_QUEUE | Number | | Maximum number of queued connection requests |
70
- | SQB_POOL_MIN_IDLE | Number | | Minimum number of idle connections to keep |
71
- | SQB_POOL_VALIDATION | Boolean | | Enables validation of connections before use |
108
+ | SQB_POOL_MAX_QUEUE | Number | | Maximum number of queued connection requests |
109
+ | SQB_POOL_MIN_IDLE | Number | | Minimum number of idle connections to keep |
110
+ | SQB_POOL_VALIDATION | Boolean | | Enables validation of connections before use |
72
111
  | SQB_POOL_HOUSE_KEEP_INTERVAL | Number | | Interval (ms) for pool housekeeping tasks |
73
112
 
74
113
  <!--- END env --->
@@ -79,17 +118,9 @@ SQB is available under [MIT](LICENSE) license.
79
118
 
80
119
  [npm-image]: https://img.shields.io/npm/v/@sqb/nestjs.svg
81
120
  [npm-url]: https://npmjs.org/package/@sqb/nestjs
82
- [travis-image]: https://img.shields.io/travis/sqbjs/@sqb/nestjs/master.svg
83
- [travis-url]: https://travis-ci.org/sqbjs/@sqb/nestjs
84
- [coveralls-image]: https://img.shields.io/coveralls/sqbjs/@sqb/nestjs/master.svg
85
- [coveralls-url]: https://coveralls.io/r/sqbjs/@sqb/nestjs
86
121
  [downloads-image]: https://img.shields.io/npm/dm/@sqb/nestjs.svg
87
122
  [downloads-url]: https://npmjs.org/package/@sqb/nestjs
88
- [gitter-image]: https://badges.gitter.im/sqbjs/@sqb/nestjs.svg
89
- [gitter-url]: https://gitter.im/sqbjs/@sqb/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
90
- [dependencies-image]: https://david-dm.org/sqbjs/@sqb/nestjs/status.svg
91
- [dependencies-url]: https://david-dm.org/sqbjs/@sqb/nestjs
92
- [devdependencies-image]: https://david-dm.org/sqbjs/@sqb/nestjs/dev-status.svg
93
- [devdependencies-url]: https://david-dm.org/sqbjs/@sqb/nestjs?type=dev
94
- [quality-image]: http://npm.packagequality.com/shield/@sqb/nestjs.png
95
- [quality-url]: http://packagequality.com/#?package=@sqb/nestjs
123
+ [ci-test-image]: https://github.com/panates/sqb/actions/workflows/test.yml/badge.svg
124
+ [ci-test-url]: https://github.com/panates/sqb/actions/workflows/test.yml
125
+ [coveralls-image]: https://coveralls.io/repos/github/sqbjs/sqb/badge.svg?branch=master
126
+ [coveralls-url]: https://coveralls.io/github/sqbjs/sqb?branch=master
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@sqb/nestjs",
3
3
  "description": "Nestjs module for data connection using SQB",
4
- "version": "5.0.6",
4
+ "version": "6.0.0",
5
5
  "author": "Panates",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
8
- "@jsopen/objects": "^2.2.3",
8
+ "@jsopen/objects": "^2.3.0",
9
9
  "ansi-colors": "^4.1.3",
10
10
  "putil-varhelpers": "^1.7.0",
11
11
  "tslib": "^2.8.1"
@@ -13,8 +13,8 @@
13
13
  "peerDependencies": {
14
14
  "@nestjs/common": ">=7.4.0",
15
15
  "@nestjs/core": ">=7.4.0",
16
- "@sqb/builder": "^5.0.6",
17
- "@sqb/connect": "^5.0.6",
16
+ "@sqb/builder": "^6.0.0",
17
+ "@sqb/connect": "^6.0.0",
18
18
  "reflect-metadata": "^0.2.2",
19
19
  "rxjs": ">=6.6.0"
20
20
  },