@tsed/mongoose 8.0.0-beta.1 → 8.0.0-beta.11
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.
|
@@ -6,7 +6,7 @@ import { schemaOptions } from "../utils/schemaOptions.js";
|
|
|
6
6
|
* define the hook function like you normally would in Mongoose.
|
|
7
7
|
*
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import {Ignore, Required} from "@tsed/
|
|
9
|
+
* import {Ignore, Required} from "@tsed/platform-http";
|
|
10
10
|
* import {PreHook, Model} from "@tsed/mongoose";
|
|
11
11
|
*
|
|
12
12
|
* @Model()
|
|
@@ -5,7 +5,7 @@ import { MongooseHookOptions, MongoosePostHookCB } from "../interfaces/MongooseS
|
|
|
5
5
|
* define the hook function like you normally would in Mongoose.
|
|
6
6
|
*
|
|
7
7
|
* ```typescript
|
|
8
|
-
* import {Ignore, Required} from "@tsed/
|
|
8
|
+
* import {Ignore, Required} from "@tsed/platform-http";
|
|
9
9
|
* import {PostHook, Model} from "@tsed/mongoose";
|
|
10
10
|
*
|
|
11
11
|
* @Model()
|
|
@@ -5,7 +5,7 @@ import { MongooseHookOptions, MongoosePreHookCB } from "../interfaces/MongooseSc
|
|
|
5
5
|
* define the hook function like you normally would in Mongoose.
|
|
6
6
|
*
|
|
7
7
|
* ```typescript
|
|
8
|
-
* import {Ignore, Required} from "@tsed/
|
|
8
|
+
* import {Ignore, Required} from "@tsed/platform-http";
|
|
9
9
|
* import {PreHook, Model} from "@tsed/mongoose";
|
|
10
10
|
*
|
|
11
11
|
* @Model()
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/mongoose",
|
|
3
3
|
"description": "Mongoose package for Ts.ED framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.0.0-beta.
|
|
5
|
+
"version": "8.0.0-beta.11",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tsed",
|
|
8
8
|
"mongoose",
|
|
@@ -33,27 +33,27 @@
|
|
|
33
33
|
"tslib": "2.7.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@tsed/ajv": "8.0.0-beta.
|
|
37
|
-
"@tsed/barrels": "8.0.0-beta.
|
|
38
|
-
"@tsed/core": "8.0.0-beta.
|
|
39
|
-
"@tsed/di": "8.0.0-beta.
|
|
40
|
-
"@tsed/json-mapper": "8.0.0-beta.
|
|
36
|
+
"@tsed/ajv": "8.0.0-beta.11",
|
|
37
|
+
"@tsed/barrels": "8.0.0-beta.11",
|
|
38
|
+
"@tsed/core": "8.0.0-beta.11",
|
|
39
|
+
"@tsed/di": "8.0.0-beta.11",
|
|
40
|
+
"@tsed/json-mapper": "8.0.0-beta.11",
|
|
41
41
|
"@tsed/logger": "^6.7.8",
|
|
42
|
-
"@tsed/schema": "8.0.0-beta.
|
|
43
|
-
"@tsed/testcontainers-mongo": "8.0.0-beta.
|
|
44
|
-
"@tsed/typescript": "8.0.0-beta.
|
|
42
|
+
"@tsed/schema": "8.0.0-beta.11",
|
|
43
|
+
"@tsed/testcontainers-mongo": "8.0.0-beta.11",
|
|
44
|
+
"@tsed/typescript": "8.0.0-beta.11",
|
|
45
45
|
"eslint": "9.12.0",
|
|
46
46
|
"mongoose": "8.7.0",
|
|
47
47
|
"typescript": "5.4.5",
|
|
48
48
|
"vitest": "2.1.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@tsed/ajv": "8.0.0-beta.
|
|
52
|
-
"@tsed/core": "8.0.0-beta.
|
|
53
|
-
"@tsed/di": "8.0.0-beta.
|
|
54
|
-
"@tsed/json-mapper": "8.0.0-beta.
|
|
51
|
+
"@tsed/ajv": "8.0.0-beta.11",
|
|
52
|
+
"@tsed/core": "8.0.0-beta.11",
|
|
53
|
+
"@tsed/di": "8.0.0-beta.11",
|
|
54
|
+
"@tsed/json-mapper": "8.0.0-beta.11",
|
|
55
55
|
"@tsed/logger": ">=6.7.5",
|
|
56
|
-
"@tsed/schema": "8.0.0-beta.
|
|
56
|
+
"@tsed/schema": "8.0.0-beta.11",
|
|
57
57
|
"mongoose": ">=6.0.0"
|
|
58
58
|
},
|
|
59
59
|
"repository": "https://github.com/tsedio/tsed",
|
package/readme.md
CHANGED
|
@@ -55,7 +55,7 @@ npm install --save-dev @types/mongoose
|
|
|
55
55
|
Then import `@tsed/mongoose` in your Server:
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
58
|
-
import {Configuration} from "@tsed/
|
|
58
|
+
import {Configuration} from "@tsed/di";
|
|
59
59
|
import "@tsed/mongoose"; // import mongoose ts.ed module
|
|
60
60
|
|
|
61
61
|
@Configuration({
|
|
@@ -76,7 +76,7 @@ The mongoose module of Ts.ED Mongoose allows to configure several basic connecti
|
|
|
76
76
|
Here is an example configuration:
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
|
-
import {Configuration} from "@tsed/
|
|
79
|
+
import {Configuration} from "@tsed/di";
|
|
80
80
|
import "@tsed/mongoose"; // import mongoose ts.ed module
|
|
81
81
|
|
|
82
82
|
@Configuration({
|
|
@@ -98,10 +98,10 @@ export class Server {}
|
|
|
98
98
|
|
|
99
99
|
## MongooseService
|
|
100
100
|
|
|
101
|
-
MongooseService let you
|
|
101
|
+
MongooseService let you retrieve an instance of Mongoose.Connection.
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
import {Service} from "@tsed/
|
|
104
|
+
import {Service} from "@tsed/di";
|
|
105
105
|
import {MongooseService} from "@tsed/mongoose";
|
|
106
106
|
|
|
107
107
|
@Service()
|
|
@@ -118,12 +118,12 @@ export class MyService {
|
|
|
118
118
|
## Declaring a Model
|
|
119
119
|
|
|
120
120
|
By default, Ts.ED mongoose will reuse the metadata stored by the decorators dedicated
|
|
121
|
-
to describe a JsonSchema.
|
|
121
|
+
to describe a JsonSchema. These decorators come from the `@tsed/schema` package.
|
|
122
122
|
|
|
123
123
|
Here a model example:
|
|
124
124
|
|
|
125
125
|
```typescript
|
|
126
|
-
import {Minimum, Maximum, MaxLength, MinLength, Enum, Pattern, Required, CollectionOf} from "@tsed/
|
|
126
|
+
import {Minimum, Maximum, MaxLength, MinLength, Enum, Pattern, Required, CollectionOf} from "@tsed/schema";
|
|
127
127
|
import {Model, Unique, Indexed, Ref, ObjectID} from "@tsed/mongoose";
|
|
128
128
|
|
|
129
129
|
enum Categories {
|
|
@@ -170,7 +170,7 @@ export class MyModel {
|
|
|
170
170
|
## Inject model
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
|
-
import {Service, Inject} from "@tsed/
|
|
173
|
+
import {Service, Inject} from "@tsed/di";
|
|
174
174
|
import {MongooseModel} from "@tsed/mongoose";
|
|
175
175
|
import {MyModel} from "./models/MyModel.js";
|
|
176
176
|
|
|
@@ -210,7 +210,7 @@ We can simply attach a `@PreHook` decorator to your model class and
|
|
|
210
210
|
define the hook function like you normally would in Mongoose.
|
|
211
211
|
|
|
212
212
|
```typescript
|
|
213
|
-
import {Required} from "@tsed/
|
|
213
|
+
import {Required} from "@tsed/schema";
|
|
214
214
|
import {PreHook, Model, ObjectID} from "@tsed/mongoose";
|
|
215
215
|
|
|
216
216
|
@Model()
|
|
@@ -249,7 +249,7 @@ We can simply attach a `@PostHook` decorator to your model class and
|
|
|
249
249
|
define the hook function like you normally would in Mongoose.
|
|
250
250
|
|
|
251
251
|
```typescript
|
|
252
|
-
import {ObjectID, Required} from "@tsed/
|
|
252
|
+
import {ObjectID, Required} from "@tsed/schema";
|
|
253
253
|
import {PostHook, Model} from "@tsed/mongoose";
|
|
254
254
|
|
|
255
255
|
@Model()
|
|
@@ -287,7 +287,7 @@ Just like the regular `schema.plugin()` call, the decorator accepts 1 or 2 param
|
|
|
287
287
|
Multiple `plugin` decorator can be used for a single model class.
|
|
288
288
|
|
|
289
289
|
```typescript
|
|
290
|
-
import {Service} from "@tsed/
|
|
290
|
+
import {Service} from "@tsed/di";
|
|
291
291
|
import {MongoosePlugin, Model, MongooseModel} from "@tsed/mongoose";
|
|
292
292
|
import * as findOrCreate from 'mongoose-findorcreate';
|
|
293
293
|
|