@mauroandre/zodmongo 0.0.1 → 0.0.2
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 +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,14 +17,14 @@ Lightweight MongoDB ODM powered by [Zod](https://zod.dev) schemas. TypeScript-fi
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install zodmongo
|
|
20
|
+
npm install @mauroandre/zodmongo
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Quick Start
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
|
-
import { connect, close, save, findMany, deleteMany } from "zodmongo";
|
|
27
|
-
import { dbSchema } from "zodmongo";
|
|
26
|
+
import { connect, close, save, findMany, deleteMany } from "@mauroandre/zodmongo";
|
|
27
|
+
import { dbSchema } from "@mauroandre/zodmongo";
|
|
28
28
|
import { z } from "zod/v4";
|
|
29
29
|
|
|
30
30
|
// Connect
|
|
@@ -64,7 +64,7 @@ await close();
|
|
|
64
64
|
Creates a schema that extends the base model with `id`, `createdAt`, and `updatedAt`. This is the primary way to define your models.
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
|
-
import { dbSchema } from "zodmongo";
|
|
67
|
+
import { dbSchema } from "@mauroandre/zodmongo";
|
|
68
68
|
import { z } from "zod/v4";
|
|
69
69
|
|
|
70
70
|
const postSchema = dbSchema({
|
|
@@ -81,7 +81,7 @@ type Post = z.infer<typeof postSchema>;
|
|
|
81
81
|
Creates a schema **without** the base model fields (`id`, `createdAt`, `updatedAt`). Use for nested objects that don't need their own identity.
|
|
82
82
|
|
|
83
83
|
```typescript
|
|
84
|
-
import { embeddedSchema } from "zodmongo";
|
|
84
|
+
import { embeddedSchema } from "@mauroandre/zodmongo";
|
|
85
85
|
import { z } from "zod/v4";
|
|
86
86
|
|
|
87
87
|
const addressSchema = embeddedSchema({
|
|
@@ -101,7 +101,7 @@ const userSchema = dbSchema({
|
|
|
101
101
|
Low-level schemas if you need to extend manually:
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
import { dbModelSchema, idSchema } from "zodmongo/schema";
|
|
104
|
+
import { dbModelSchema, idSchema } from "@mauroandre/zodmongo/schema";
|
|
105
105
|
|
|
106
106
|
const customSchema = dbModelSchema.extend({
|
|
107
107
|
name: z.string(),
|
|
@@ -310,7 +310,7 @@ ZodMongo automatically handles conversions between your app's `id` (string) and
|
|
|
310
310
|
Use `trackPromise()` to register fire-and-forget operations. `close()` waits for all tracked promises before disconnecting.
|
|
311
311
|
|
|
312
312
|
```typescript
|
|
313
|
-
import { trackPromise, close } from "zodmongo";
|
|
313
|
+
import { trackPromise, close } from "@mauroandre/zodmongo";
|
|
314
314
|
|
|
315
315
|
trackPromise(save("logs", logEntry));
|
|
316
316
|
trackPromise(save("logs", anotherEntry));
|