@zodyac/zod-mongoose 1.0.6 → 1.0.7
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 +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ This package provides a function to convert [zod](https://www.npmjs.com/package/
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm i @zodyac/mongoose
|
|
12
|
+
npm i @zodyac/zod-mongoose
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
@@ -18,7 +18,7 @@ First, create your zod schema:
|
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
20
|
import { z } from 'zod';
|
|
21
|
-
import { zId } from '@zodyac/mongoose';
|
|
21
|
+
import { zId } from '@zodyac/zod-mongoose';
|
|
22
22
|
|
|
23
23
|
const zUser = z.object({
|
|
24
24
|
name: z.string().min(3).max(255),
|
|
@@ -41,7 +41,7 @@ const zUser = z.object({
|
|
|
41
41
|
Then, convert it to mongoose schema and connect model:
|
|
42
42
|
|
|
43
43
|
```typescript
|
|
44
|
-
import { zodSchema } from '@zodyac/mongoose';
|
|
44
|
+
import { zodSchema } from '@zodyac/zod-mongoose';
|
|
45
45
|
import { model } from 'mongoose';
|
|
46
46
|
|
|
47
47
|
const schema = zodSchema(zDoc);
|
|
@@ -89,7 +89,7 @@ console.log(schema.obj);
|
|
|
89
89
|
If you want to get raw object from zod schema to modify it, you can use ```zodSchemaRaw``` function:
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
|
-
import { zodSchemaRaw } from '@zodyac/mongoose';
|
|
92
|
+
import { zodSchemaRaw } from '@zodyac/zod-mongoose';
|
|
93
93
|
import { model, Schema } from 'mongoose';
|
|
94
94
|
|
|
95
95
|
const schema = zodSchemaRaw(zDoc);
|