Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/mongo-demo/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
MongoLimitStage,
MongoSortStage,
} from '@prisma-next/mongo-query-ast/execution';
import { acc, fn } from '@prisma-next/mongo-query-builder';
import { acc } from '@prisma-next/mongo-query-builder';
import type { Db } from './db';
import { createClient } from './db';
import { seed } from './seed';
Expand Down Expand Up @@ -80,7 +80,7 @@ export async function getRecentPostSummaries(query: Db['query'], runtime: Db['ru
.from('posts')
.sort({ createdAt: -1 })
.limit(3)
.addFields((f) => ({
.addFields((f, fn) => ({
titleUpper: fn.toUpper(f.title),
}))
.project('title', 'titleUpper', 'authorId', 'createdAt')
Expand Down
9 changes: 7 additions & 2 deletions examples/mongo-demo/test/cache-middleware.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import mongoRuntimeAdapter from '@prisma-next/adapter-mongo/runtime';
import mongoRuntimeAdapter, {
type MongoOperationOutputCodecs,
} from '@prisma-next/adapter-mongo/runtime';
import { createMongoDriver } from '@prisma-next/driver-mongo';
import { MongoContractSerializer } from '@prisma-next/family-mongo/ir';
import type { CachePayload } from '@prisma-next/middleware-cache';
Expand Down Expand Up @@ -77,7 +79,10 @@ describe('mongo-demo cache middleware integration', {
const cache = createCacheMiddleware({ maxEntries: 100 });
const runtime = createMongoRuntime({ context, driver, middleware: [cache] });
const orm = mongoOrm({ contract, executor: runtime });
const query = mongoQuery<Contract>({ contractJson });
const query = mongoQuery<Contract, MongoOperationOutputCodecs>({
contractJson: contract,
operationCodecs: mongoRuntimeAdapter.operationOutputCodecs,
});
return { runtime, orm, query, driver, driverExecuteSpy };
}

Expand Down
9 changes: 7 additions & 2 deletions examples/mongo-demo/test/query-builder-writes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import mongoRuntimeAdapter from '@prisma-next/adapter-mongo/runtime';
import mongoRuntimeAdapter, {
type MongoOperationOutputCodecs,
} from '@prisma-next/adapter-mongo/runtime';
import { createMongoDriver } from '@prisma-next/driver-mongo';
import { MongoContractSerializer } from '@prisma-next/family-mongo/ir';
import { mongoQuery } from '@prisma-next/mongo-query-builder';
Expand All @@ -18,7 +20,10 @@ import contractJson from '../src/contract.json' with { type: 'json' };

const contract = new MongoContractSerializer().deserializeContract<Contract>(contractJson);

const q = mongoQuery<Contract>({ contractJson: contract });
const q = mongoQuery<Contract, MongoOperationOutputCodecs>({
contractJson: contract,
operationCodecs: mongoRuntimeAdapter.operationOutputCodecs,
});

describe('query-builder write terminals (integration)', {
timeout: timeouts.spinUpMongoMemoryServer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { MongoAggExpr } from '@prisma-next/mongo-query-ast/execution';
import { MongoAggAccumulator, MongoAggLiteral } from '@prisma-next/mongo-query-ast/execution';
import type {
ArrayField,
DocField,
NullableNumericField,
NumericField,
TypedAccumulatorExpr,
TypedAggExpr,
} from './types';
import type { DocField, TypedAccumulatorExpr, TypedAggExpr } from './types';

// TML-2964: `acc` still carries hardcoded codec-id literals; it becomes
// context-bound like `fn`. Private aliases so the rest of the package
// carries no codec-id literals.
type NumericField = { readonly codecId: 'mongo/double@1'; readonly nullable: false };
type NullableNumericField = { readonly codecId: 'mongo/double@1'; readonly nullable: true };
type ArrayField = { readonly codecId: 'mongo/array@1'; readonly nullable: false };

function namedAccumulatorArgs(
args: Readonly<Record<string, TypedAggExpr<DocField> | undefined>>,
Expand Down
Loading
Loading