From 9d17a0dbfd602c4f28e6d4ed7b6d62f9aba49ab0 Mon Sep 17 00:00:00 2001 From: Montgomery Watts Date: Mon, 4 Jul 2022 20:01:36 -0700 Subject: [PATCH 1/2] Update schematypes.md Expand description of `min` and `max` and include `expires` option for Date schema type. --- docs/schematypes.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/schematypes.md b/docs/schematypes.md index dc64c571340..74ca0700efa 100644 --- a/docs/schematypes.md +++ b/docs/schematypes.md @@ -279,8 +279,9 @@ const schema2 = new Schema({
Date
-* `min`: Date -* `max`: Date +* `min`: Date, creates a [validator](./validation.html) that checks if the value is greater than or equal to the given minimum. +* `max`: Date, creates a [validator](./validation.html) that checks if the value is less than or equal to the given maximum. +* `expires`: Number or String, creates a TTL index with the value expressed in seconds.
ObjectId
From 499f49957fa41505b8eebe3a8b6dcef06cc53dfe Mon Sep 17 00:00:00 2001 From: Luca Pizzini Date: Tue, 5 Jul 2022 09:55:14 +0200 Subject: [PATCH 2/2] fix benchmark --- benchmarks/benchjs/casting.js | 26 +++++++++++++------------- benchmarks/benchjs/delete.js | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/benchmarks/benchjs/casting.js b/benchmarks/benchjs/casting.js index f236070b5e1..f7027eed6b0 100644 --- a/benchmarks/benchjs/casting.js +++ b/benchmarks/benchjs/casting.js @@ -24,7 +24,7 @@ Comments.add({ title: String, date: Date, body: String, - comments: [Comments] + comments: [Comments], }); const BlogPost = new Schema({ @@ -34,7 +34,7 @@ const BlogPost = new Schema({ date: Date, meta: { date: Date, - visitors: Number + visitors: Number, }, published: Boolean, mixed: {}, @@ -44,15 +44,15 @@ const BlogPost = new Schema({ comments: [Comments], def: { type: String, - default: 'kandinsky' - } + default: 'kandinsky', + }, }); const commentData = { title: 'test comment', date: new Date(), body: 'this be some crazzzyyyyy text that would go in a comment', - comments: [{ title: 'second level', date: new Date(), body: 'texttt' }] + comments: [{ title: 'second level', date: new Date(), body: 'texttt' }], }; const blogData = { @@ -62,16 +62,16 @@ const blogData = { date: new Date(), meta: { date: new Date(), - visitors: 9001 + visitors: 9001, }, published: true, mixed: { - thisIsRandom: true + thisIsRandom: true, }, numbers: [1, 2, 7, 10, 23432], tags: ['test', 'BENCH', 'things', 'more things'], def: 'THANGS!!!', - comments: [] + comments: [], }; const blogData10 = utils.clone(blogData); @@ -100,35 +100,35 @@ suite const BlogPost = mongoose.model('BlogPost'); const bp = new BlogPost(); bp.init(blogData); - } + }, }) .add('Casting - Embedded Docs - 10 Docs', { fn: function () { const BlogPost = mongoose.model('BlogPost'); const bp = new BlogPost(); bp.init(blogData10); - } + }, }) .add('Casting - Embedded Docs - 100 Docs', { fn: function () { const BlogPost = mongoose.model('BlogPost'); const bp = new BlogPost(); bp.init(blogData100); - } + }, }) .add('Casting - Embedded Docs - 1000 Docs', { fn: function () { const BlogPost = mongoose.model('BlogPost'); const bp = new BlogPost(); bp.init(blogData1000); - } + }, }) .add('Casting - Embedded Docs - 10000 Docs', { fn: function () { const BlogPost = mongoose.model('BlogPost'); const bp = new BlogPost(); bp.init(blogData10000); - } + }, }) .on('cycle', function (evt) { if (process.env.MONGOOSE_DEV || process.env.PULL_REQUEST) { diff --git a/benchmarks/benchjs/delete.js b/benchmarks/benchjs/delete.js index 4d7cfc4bdf6..705c8091fe1 100644 --- a/benchmarks/benchjs/delete.js +++ b/benchmarks/benchjs/delete.js @@ -64,7 +64,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) { nData.likes = data.likes; nData.address = data.address; user.insertOne(nData, function (err, res) { - dIds.push(res.insertedIds); + dIds.push(res.insertedId); --count || next(); }); }