Skip to content

Commit 4540a29

Browse files
authored
Merge pull request #11053 from Automattic/6.1
6.1
2 parents 43bf92d + 835814e commit 4540a29

33 files changed

+763
-62
lines changed

docs/guide.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ Valid options:
417417
- [versionKey](#versionKey)
418418
- [optimisticConcurrency](#optimisticConcurrency)
419419
- [collation](#collation)
420+
- [timeseries](#timeseries)
420421
- [selectPopulatedPaths](#selectPopulatedPaths)
421422
- [skipVersioning](#skipVersioning)
422423
- [timestamps](#timestamps)
@@ -1063,6 +1064,25 @@ MyModel.create([{ name: 'val' }, { name: 'Val' }]).
10631064
});
10641065
```
10651066

1067+
<h3 id="timeseries"><a href="#timeseries">option: timeseries</a></h3>
1068+
1069+
If you set the `timeseries` option on a schema, Mongoose will create a [timeseries collection](https://docs.mongodb.com/manual/core/timeseries-collections/) for any model that you create from that schema.
1070+
1071+
```javascript
1072+
const schema = Schema({ name: String, timestamp: Date, metadata: Object }, {
1073+
timeseries: {
1074+
timeField: 'timestamp',
1075+
metaField: 'metadata',
1076+
granularity: 'hours'
1077+
},
1078+
autoCreate: false,
1079+
expireAfterSeconds: 86400
1080+
});
1081+
1082+
// `Test` collection will be a timeseries collection
1083+
const Test = db.model('Test', schema);
1084+
```
1085+
10661086
<h3 id="skipVersioning"><a href="#skipVersioning">option: skipVersioning</a></h3>
10671087

10681088
`skipVersioning` allows excluding paths from versioning (i.e., the internal

0 commit comments

Comments
 (0)