Skip to content

Commit c9c1dd2

Browse files
added unit test
testing fix testing fix 2
1 parent e292a79 commit c9c1dd2

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

Diff for: src/mongo_types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export type PullAllOperator<TSchema> = ({
283283
export type UpdateFilter<TSchema> = {
284284
$currentDate?: OnlyFieldsOfType<
285285
TSchema,
286-
Date | Timestamp,
286+
Date | Timestamp | true,
287287
true | { $type: 'date' | 'timestamp' }
288288
>;
289289
$inc?: OnlyFieldsOfType<TSchema, NumericType | undefined>;

Diff for: test/integration/crud/find_and_modify.test.ts

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { expect } from 'chai';
22

3-
import { type CommandStartedEvent, MongoServerError, ObjectId } from '../../mongodb';
3+
import {
4+
type Collection,
5+
type CommandStartedEvent,
6+
type Db,
7+
MongoServerError,
8+
ObjectId
9+
} from '../../mongodb';
410
import { setupDatabase } from '../shared';
511

612
describe('Collection (#findOneAnd...)', function () {
@@ -324,6 +330,35 @@ describe('Collection (#findOneAnd...)', function () {
324330
});
325331
});
326332
});
333+
334+
describe('update filter', function () {
335+
context('when $currentDate is provided', function () {
336+
let client;
337+
let db: Db;
338+
let collection: Collection;
339+
340+
beforeEach(async function () {
341+
client = this.configuration.newClient({ w: 1 });
342+
await client.connect();
343+
db = client.db(this.configuration.db);
344+
collection = db.collection('test_coll');
345+
await collection.insertOne({ a: 'c' });
346+
});
347+
348+
afterEach(async function () {
349+
await collection.drop();
350+
await client.close();
351+
});
352+
353+
it(`should support fields with value 'true'`, async function () {
354+
await collection.findOneAndUpdate(
355+
{},
356+
{ $set: { a: 1 }, $currentDate: { lastModified: true } },
357+
{ writeConcern: { w: 1 } }
358+
);
359+
});
360+
});
361+
});
327362
});
328363

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

0 commit comments

Comments
 (0)