Skip to content

Commit

Permalink
feat(alive signal): add automatic document deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmogVC committed Dec 20, 2019
1 parent a932a9b commit 32eced9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/aliveSignal/aliveSignal.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as mongoose from 'mongoose';
import IAliveSignal from './aliveSignal.interface';
import config from '../config';

// TODO: Remove document after specified (in config) amount of time.
const aliveSignalSchema: mongoose.Schema = new mongoose.Schema(
Expand All @@ -20,11 +21,15 @@ const aliveSignalSchema: mongoose.Schema = new mongoose.Schema(
type: Date,
required: true,
},
createdAt: {
type: Date,
default: new Date(),
expires: config.aliveSignal.expirationTimeInSeconds,
},
},
{
versionKey: false,
autoIndex: false,
timestamps: { createdAt: true, updatedAt: false },
id: true,
toJSON: {
virtuals: true,
Expand Down

0 comments on commit 32eced9

Please sign in to comment.