Skip to content

Commit

Permalink
fix: disallow null id (fixes tests!)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Jan 31, 2023
1 parent a7ea997 commit 3797abd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mongo.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
AnyObjectWithId,
CommonLogger,
commonLoggerPrefix,
_assert,
} from '@naturalcycles/js-lib'
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
import { CommandOperationOptions, Filter, MongoClient, MongoClientOptions } from 'mongodb'
Expand Down Expand Up @@ -112,6 +113,8 @@ export class MongoDB extends BaseCommonDB implements CommonDB {
): Promise<void> {
if (!rows.length) return

_assert(!rows.some(r => r.id === null), `id cannot be null in saveBatch`)

const client = await this.client()
await client
.db(this.cfg.db)
Expand Down

0 comments on commit 3797abd

Please sign in to comment.