Browse Source

wipExpiredAt -> ttlTimestamp

Shun Miyazawa 2 years ago
parent
commit
c5b8c9348c

+ 4 - 4
apps/app/src/server/models/page.ts

@@ -140,7 +140,7 @@ const schema = new Schema<PageDocument, PageModel>({
   commentCount: { type: Number, default: 0 },
   expandContentWidth: { type: Boolean },
   wip: { type: Boolean },
-  wipExpiredAt: { type: Date, index: true },
+  ttlTimestamp: { type: Date, index: true },
   updatedAt: { type: Date, default: Date.now }, // Do not use timetamps for updatedAt because it breaks 'updateMetadata: false' option
   deleteUser: { type: ObjectId, ref: 'User' },
   deletedAt: { type: Date },
@@ -1055,17 +1055,17 @@ schema.methods.calculateAndUpdateLatestRevisionBodyLength = async function(this:
 
 schema.methods.publish = function() {
   this.wip = undefined;
-  this.wipExpiredAt = undefined;
+  this.ttlTimestamp = undefined;
 };
 
 schema.methods.unpublish = function() {
   this.wip = true;
-  this.wipExpiredAt = undefined;
+  this.ttlTimestamp = undefined;
 };
 
 schema.methods.makeWip = function() {
   this.wip = true;
-  this.wipExpiredAt = new Date();
+  this.ttlTimestamp = new Date();
 };
 
 /*

+ 2 - 2
apps/app/src/server/service/page/index.ts

@@ -4413,7 +4413,7 @@ class PageService implements IPageService {
     const collection = mongoose.connection.collection('pages');
 
     try {
-      const targetField = 'wipExpiredAt_1';
+      const targetField = 'ttlTimestamp_1';
 
       const indexes = await collection.indexes();
       const foundTargetField = indexes.find(i => i.name === targetField);
@@ -4427,7 +4427,7 @@ class PageService implements IPageService {
       }
 
       if (shoudCreateIndex) {
-        await collection.createIndex({ wipExpiredAt: 1 }, { expireAfterSeconds: pageExpirationSeconds });
+        await collection.createIndex({ ttlTimestamp: 1 }, { expireAfterSeconds: pageExpirationSeconds });
       }
     }
     catch (err) {

+ 1 - 1
packages/core/src/interfaces/page.ts

@@ -40,7 +40,7 @@ export type IPage = {
   latestRevisionBodyLength?: number,
   expandContentWidth?: boolean,
   wip?: boolean,
-  wipExpiredAt?: Date
+  ttlTimestamp?: Date
 }
 
 export type IPagePopulatedToList = Omit<IPageHasId, 'lastUpdateUser'> & {