Skip to content

Commit 5d0e6a4

Browse files
added unit test
1 parent e292a79 commit 5d0e6a4

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/mongo_types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ export type PullAllOperator<TSchema> = ({
283283
export type UpdateFilter<TSchema> = {
284284
$currentDate?: OnlyFieldsOfType<
285285
TSchema,
286-
Date | Timestamp,
287-
true | { $type: 'date' | 'timestamp' }
286+
Date | Timestamp | true,
287+
{ $type: 'date' | 'timestamp' }
288288
>;
289289
$inc?: OnlyFieldsOfType<TSchema, NumericType | undefined>;
290290
$min?: MatchKeysAndValues<TSchema>;

test/integration/crud/find_and_modify.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai';
22

3-
import { type CommandStartedEvent, MongoServerError, ObjectId } from '../../mongodb';
3+
import { type Collection, type CommandStartedEvent, type Db, MongoServerError, ObjectId } from '../../mongodb';
44
import { setupDatabase } from '../shared';
55

66
describe('Collection (#findOneAnd...)', function () {
@@ -324,6 +324,31 @@ describe('Collection (#findOneAnd...)', function () {
324324
});
325325
});
326326
});
327+
328+
describe('update filter', function () {
329+
context('when $currentDate is provided', function () {
330+
let client;
331+
let db: Db;
332+
let collection: Collection;
333+
334+
beforeEach(async function () {
335+
client = this.configuration.newClient({ w: 1 });
336+
await client.connect();
337+
db = client.db(this.configuration.db);
338+
collection = db.collection('test_coll');
339+
await collection.insertOne({ a: 'c' });
340+
});
341+
342+
afterEach(async function () {
343+
await collection.drop();
344+
await client.close();
345+
});
346+
347+
it(`should support fields with value 'true'`, async function () {
348+
await collection.findOneAndUpdate({}, { $set: { a: 1 }, $currentDate: { lastModified: true } }, { writeConcern: { w: 1 } });
349+
});
350+
});
351+
});
327352
});
328353

329354
describe('#findOneAndReplace', function () {

0 commit comments

Comments
 (0)