Skip to content

Commit

Permalink
Merge pull request #11489 from Uzlopak/fix-missing-expirationhandling…
Browse files Browse the repository at this point in the history
…-for-timeseries

fix: add missing timeseries expiration handling
  • Loading branch information
vkarpov15 committed Mar 15, 2022
2 parents f5fe027 + 478943a commit 1f109ea
Show file tree
Hide file tree
Showing 7 changed files with 400 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
tar xf mongodb-linux-x86_64-${{ matrix.mongo-os }}-${{ matrix.mongo }}.tgz
mkdir -p ./data/db/27017 ./data/db/27000
printf "\n--timeout 8000" >> ./test/mocha.opts
./mongodb-linux-x86_64-${{ matrix.mongo-os }}-${{ matrix.mongo }}/bin/mongod --fork --dbpath ./data/db/27017 --syslog --port 27017
./mongodb-linux-x86_64-${{ matrix.mongo-os }}-${{ matrix.mongo }}/bin/mongod --setParameter ttlMonitorSleepSecs=1 --fork --dbpath ./data/db/27017 --syslog --port 27017
sleep 2
mongod --version
echo `pwd`/mongodb-linux-x86_64-${{ matrix.mongo-os }}-${{ matrix.mongo }}/bin >> $GITHUB_PATH
Expand Down
10 changes: 10 additions & 0 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,16 @@ Model.createCollection = function createCollection(options, callback) {
this.schema.options.timeseries;
if (timeseries != null) {
options = Object.assign({ timeseries }, options);
if (options.expireAfterSeconds != null) {
// do nothing
} else if (options.expires != null) {
utils.expires(options);
} else if (this.schema.options.expireAfterSeconds != null) {
options.expireAfterSeconds = this.schema.options.expireAfterSeconds;
} else if (this.schema.options.expires != null) {
options.expires = this.schema.options.expires;
utils.expires(options);
}
}

callback = this.$handleCallbackError(callback);
Expand Down

0 comments on commit 1f109ea

Please sign in to comment.