Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed custom sql operations typing in PongoCollection typing and Find methods results #90

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Changes from 1 commit
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
Next Next commit
Fixed custom sql operations typing in PongoCollection type
oskardudycz committed Oct 2, 2024
commit 91d5f40dce91d1922fe57669039a61a904dfd723
2 changes: 1 addition & 1 deletion src/packages/dumbo/src/postgres/pg/execute/execute.ts
Original file line number Diff line number Diff line change
@@ -88,8 +88,8 @@ async function batch<Result extends QueryResultRow = QueryResultRow>(

//TODO: make it smarter at some point
for (let i = 0; i < sqls.length; i++) {
const result = await client.query<Result>(sqls[i]!);
tracer.info('db:sql:query', { sql: sqls[i]! });
const result = await client.query<Result>(sqls[i]!);
results[i] = { rowCount: result.rowCount, rows: result.rows };
}
return Array.isArray(sqlOrSqls) ? results : results[0]!;
28 changes: 14 additions & 14 deletions src/packages/pongo/src/core/typing/operations.ts
Original file line number Diff line number Diff line change
@@ -134,52 +134,52 @@ export interface PongoCollection<T extends PongoDocument> {
options?: CollectionOperationOptions,
): Promise<PongoInsertManyResult>;
updateOne(
filter: PongoFilter<T>,
update: PongoUpdate<T>,
filter: PongoFilter<T> | SQL,
update: PongoUpdate<T> | SQL,
options?: UpdateOneOptions,
): Promise<PongoUpdateResult>;
replaceOne(
filter: PongoFilter<T>,
filter: PongoFilter<T> | SQL,
document: WithoutId<T>,
options?: ReplaceOneOptions,
): Promise<PongoUpdateResult>;
updateMany(
filter: PongoFilter<T>,
update: PongoUpdate<T>,
filter: PongoFilter<T> | SQL,
update: PongoUpdate<T> | SQL,
options?: UpdateManyOptions,
): Promise<PongoUpdateManyResult>;
deleteOne(
filter?: PongoFilter<T>,
filter?: PongoFilter<T> | SQL,
options?: DeleteOneOptions,
): Promise<PongoDeleteResult>;
deleteMany(
filter?: PongoFilter<T>,
filter?: PongoFilter<T> | SQL,
options?: DeleteManyOptions,
): Promise<PongoDeleteResult>;
findOne(
filter?: PongoFilter<T>,
filter?: PongoFilter<T> | SQL,
options?: CollectionOperationOptions,
): Promise<T | null>;
find(
filter?: PongoFilter<T>,
filter?: PongoFilter<T> | SQL,
options?: CollectionOperationOptions,
): Promise<T[]>;
findOneAndDelete(
filter: PongoFilter<T>,
filter: PongoFilter<T> | SQL,
options?: DeleteOneOptions,
): Promise<T | null>;
findOneAndReplace(
filter: PongoFilter<T>,
filter: PongoFilter<T> | SQL,
replacement: WithoutId<T>,
options?: ReplaceOneOptions,
): Promise<T | null>;
findOneAndUpdate(
filter: PongoFilter<T>,
update: PongoUpdate<T>,
filter: PongoFilter<T> | SQL,
update: PongoUpdate<T> | SQL,
options?: UpdateOneOptions,
): Promise<T | null>;
countDocuments(
filter?: PongoFilter<T>,
filter?: PongoFilter<T> | SQL,
options?: CollectionOperationOptions,
): Promise<number>;
drop(options?: CollectionOperationOptions): Promise<boolean>;