@@ -18,7 +18,7 @@ Mizzle ORM's middleware system allows you to intercept and modify database opera
1818Apply middleware to all collections:
1919
2020``` typescript
21- import { mizzle , loggingMiddleware , performanceMiddleware } from ' mizzle-orm' ;
21+ import { mizzle , loggingMiddleware , performanceMiddleware } from ' @ mizzle-dev/ orm' ;
2222
2323const db = await mizzle ({
2424 uri: process .env .MONGO_URI ! ,
@@ -36,7 +36,7 @@ const db = await mizzle({
3636Apply middleware to specific collections:
3737
3838``` typescript
39- import { mongoCollection , auditMiddleware } from ' mizzle-orm' ;
39+ import { mongoCollection , auditMiddleware } from ' @ mizzle-dev/ orm' ;
4040
4141const users = mongoCollection (
4242 ' users' ,
@@ -62,7 +62,7 @@ A middleware is a function that receives:
62622 . ** Next** (` () => Promise<TResult> ` ) - Function to call the next middleware or operation
6363
6464``` typescript
65- import type { Middleware } from ' mizzle-orm' ;
65+ import type { Middleware } from ' @ mizzle-dev/ orm' ;
6666
6767const myMiddleware: Middleware = async (ctx , next ) => {
6868 // Before operation
@@ -142,7 +142,7 @@ await db().users.create({...});
142142Log all database operations:
143143
144144``` typescript
145- import { loggingMiddleware } from ' mizzle-orm' ;
145+ import { loggingMiddleware } from ' @ mizzle-dev/ orm' ;
146146
147147loggingMiddleware ({
148148 level: ' info' , // 'debug' | 'info' | 'warn' | 'error'
@@ -163,7 +163,7 @@ loggingMiddleware({
163163Track query execution times and detect slow queries:
164164
165165``` typescript
166- import { performanceMiddleware } from ' mizzle-orm' ;
166+ import { performanceMiddleware } from ' @ mizzle-dev/ orm' ;
167167
168168performanceMiddleware ({
169169 slowQueryThreshold: 1000 , // Warn if query takes > 1000ms
@@ -183,7 +183,7 @@ performanceMiddleware({
183183Cache read operations to reduce database load:
184184
185185``` typescript
186- import { cachingMiddleware , MemoryCacheStore } from ' mizzle-orm' ;
186+ import { cachingMiddleware , MemoryCacheStore } from ' @ mizzle-dev/ orm' ;
187187import Redis from ' ioredis' ;
188188
189189// Option 1: In-memory cache
@@ -219,7 +219,7 @@ cachingMiddleware({
219219Log all write operations for compliance:
220220
221221``` typescript
222- import { auditMiddleware } from ' mizzle-orm' ;
222+ import { auditMiddleware } from ' @ mizzle-dev/ orm' ;
223223
224224auditMiddleware ({
225225 store: {
@@ -250,7 +250,7 @@ auditMiddleware({
250250Automatically retry failed operations:
251251
252252``` typescript
253- import { retryMiddleware } from ' mizzle-orm' ;
253+ import { retryMiddleware } from ' @ mizzle-dev/ orm' ;
254254
255255retryMiddleware ({
256256 maxRetries: 3 ,
@@ -273,7 +273,7 @@ retryMiddleware({
273273Validate data before write operations:
274274
275275``` typescript
276- import { validationMiddleware , ValidationError } from ' mizzle-orm' ;
276+ import { validationMiddleware , ValidationError } from ' @ mizzle-dev/ orm' ;
277277import { z } from ' zod' ;
278278
279279const userSchema = z .object ({
@@ -313,7 +313,7 @@ try {
313313Combine multiple middlewares into one:
314314
315315``` typescript
316- import { compose , loggingMiddleware , performanceMiddleware } from ' mizzle-orm' ;
316+ import { compose , loggingMiddleware , performanceMiddleware } from ' @ mizzle-dev/ orm' ;
317317
318318const observability = compose (
319319 loggingMiddleware ({ level: ' info' }),
@@ -331,7 +331,7 @@ const db = await mizzle({
331331Conditionally apply middleware:
332332
333333``` typescript
334- import { when } from ' mizzle-orm' ;
334+ import { when } from ' @ mizzle-dev/ orm' ;
335335
336336const cacheInProduction = when (
337337 (ctx ) => process .env .NODE_ENV === ' production' ,
@@ -344,7 +344,7 @@ const cacheInProduction = when(
344344Apply middleware to specific operations:
345345
346346``` typescript
347- import { onOperations , auditMiddleware } from ' mizzle-orm' ;
347+ import { onOperations , auditMiddleware } from ' @ mizzle-dev/ orm' ;
348348
349349const auditWrites = onOperations (
350350 [' create' , ' update' , ' updateById' , ' delete' , ' deleteById' ],
@@ -357,7 +357,7 @@ const auditWrites = onOperations(
357357Apply middleware to read or write operations:
358358
359359``` typescript
360- import { onReads , onWrites , cachingMiddleware , auditMiddleware } from ' mizzle-orm' ;
360+ import { onReads , onWrites , cachingMiddleware , auditMiddleware } from ' @ mizzle-dev/ orm' ;
361361
362362const db = await mizzle ({
363363 middlewares: [
@@ -373,7 +373,7 @@ const db = await mizzle({
373373Apply middleware to specific collections:
374374
375375``` typescript
376- import { onCollections , auditMiddleware } from ' mizzle-orm' ;
376+ import { onCollections , auditMiddleware } from ' @ mizzle-dev/ orm' ;
377377
378378const auditSensitiveCollections = onCollections (
379379 [' users' , ' payments' , ' auth_tokens' ],
@@ -386,7 +386,7 @@ const auditSensitiveCollections = onCollections(
386386### Basic Custom Middleware
387387
388388``` typescript
389- import type { Middleware } from ' mizzle-orm' ;
389+ import type { Middleware } from ' @ mizzle-dev/ orm' ;
390390
391391const requestIdMiddleware: Middleware = async (ctx , next ) => {
392392 // Add request ID to context if not present
@@ -543,7 +543,7 @@ const queryRewritingMiddleware: Middleware = async (ctx, next) => {
543543import { trace , context } from ' @opentelemetry/api' ;
544544
545545const tracingMiddleware: Middleware = async (ctx , next ) => {
546- const tracer = trace .getTracer (' mizzle-orm' );
546+ const tracer = trace .getTracer (' @ mizzle-dev/ orm' );
547547
548548 return tracer .startActiveSpan (
549549 ` ${ctx .collection }.${ctx .operation } ` ,
@@ -668,7 +668,7 @@ const myMiddleware: Middleware = async (ctx, next) => {
668668
669669``` typescript
670670import { describe , it , expect } from ' vitest' ;
671- import type { Middleware , MiddlewareContext } from ' mizzle-orm' ;
671+ import type { Middleware , MiddlewareContext } from ' @ mizzle-dev/ orm' ;
672672
673673describe (' myMiddleware' , () => {
674674 it (' should execute correctly' , async () => {
0 commit comments