@chevre/domain 26.0.0-alpha.26 → 26.0.0-alpha.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,131 @@
1
+ import type { Connection } from 'mongoose';
2
+ import { factory } from '../factory';
3
+ import { IDocType } from './mongoose/schemas/transaction';
4
+ /**
5
+ * 取引管理リポジトリ
6
+ */
7
+ export declare class AdminTransactionRepo {
8
+ private readonly transactionModel;
9
+ constructor(connection: Connection);
10
+ countPotentiallyExportTasks(params: {
11
+ endDate: {
12
+ $lt: Date;
13
+ };
14
+ limit?: number;
15
+ }): Promise<{
16
+ count: number;
17
+ }>;
18
+ /**
19
+ * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
20
+ * PotentialActionStatusに変更する
21
+ * 2025-03-10~
22
+ */
23
+ reExportAction(params: {
24
+ startDate: {
25
+ $lt: Date;
26
+ };
27
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
28
+ /**
29
+ * add(2025-03-13~)
30
+ */
31
+ countPotentiallyExpired(params: {
32
+ expires: {
33
+ $lt: Date;
34
+ };
35
+ limit?: number;
36
+ }): Promise<{
37
+ count: number;
38
+ }>;
39
+ /**
40
+ * add(2025-03-03~)
41
+ */
42
+ makeOneExpiredIfExists(params: {
43
+ expires: {
44
+ $lt: Date;
45
+ };
46
+ }): Promise<Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'typeOf'> | undefined>;
47
+ findByIdAndDelete(params: {
48
+ id: string;
49
+ }): Promise<void>;
50
+ unsetUnnecessaryFields(params: {
51
+ filter: any;
52
+ $unset: any;
53
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
54
+ getCursor(conditions: any, projection: any, sort?: factory.sortType): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & (({
55
+ object: import("@chevre/factory/lib/chevre/transaction/placeOrder").IObject;
56
+ error?: any;
57
+ project: import("@chevre/factory/lib/chevre/transaction").IProject;
58
+ seller: import("@chevre/factory/lib/chevre/transaction/placeOrder").ISeller;
59
+ typeOf: factory.transactionType.PlaceOrder;
60
+ expires: Date;
61
+ result?: import("@chevre/factory/lib/chevre/transaction/placeOrder").IResult | undefined;
62
+ startDate: Date;
63
+ endDate?: Date | undefined;
64
+ instrument?: import("@chevre/factory/lib/chevre/transaction/placeOrder").IInstrument | undefined;
65
+ agent: import("@chevre/factory/lib/chevre/transaction/placeOrder").IAgent;
66
+ status: factory.transactionStatusType;
67
+ tasksExportAction?: import("@chevre/factory/lib/chevre/transaction").ITasksExportAction | undefined;
68
+ potentialActions?: undefined;
69
+ } & {
70
+ _id: import("mongoose").Types.ObjectId;
71
+ } & {
72
+ __v: number;
73
+ }) | ({
74
+ object: import("@chevre/factory/lib/chevre/transaction/returnOrder").IObject;
75
+ error?: any;
76
+ project: import("@chevre/factory/lib/chevre/transaction").IProject;
77
+ seller: import("@chevre/factory/lib/chevre/transaction").ISeller;
78
+ typeOf: factory.transactionType.ReturnOrder;
79
+ expires: Date;
80
+ result?: import("@chevre/factory/lib/chevre/transaction/returnOrder").IResult | undefined;
81
+ startDate: Date;
82
+ endDate?: Date | undefined;
83
+ agent: import("@chevre/factory/lib/chevre/transaction").IAgent;
84
+ recipient?: undefined;
85
+ status: factory.transactionStatusType;
86
+ tasksExportAction?: import("@chevre/factory/lib/chevre/transaction").ITasksExportAction | undefined;
87
+ potentialActions?: import("@chevre/factory/lib/chevre/transaction/returnOrder").IPotentialActions | undefined;
88
+ } & {
89
+ _id: import("mongoose").Types.ObjectId;
90
+ } & {
91
+ __v: number;
92
+ })), import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & (({
93
+ object: import("@chevre/factory/lib/chevre/transaction/placeOrder").IObject;
94
+ error?: any;
95
+ project: import("@chevre/factory/lib/chevre/transaction").IProject;
96
+ seller: import("@chevre/factory/lib/chevre/transaction/placeOrder").ISeller;
97
+ typeOf: factory.transactionType.PlaceOrder;
98
+ expires: Date;
99
+ result?: import("@chevre/factory/lib/chevre/transaction/placeOrder").IResult | undefined;
100
+ startDate: Date;
101
+ endDate?: Date | undefined;
102
+ instrument?: import("@chevre/factory/lib/chevre/transaction/placeOrder").IInstrument | undefined;
103
+ agent: import("@chevre/factory/lib/chevre/transaction/placeOrder").IAgent;
104
+ status: factory.transactionStatusType;
105
+ tasksExportAction?: import("@chevre/factory/lib/chevre/transaction").ITasksExportAction | undefined;
106
+ potentialActions?: undefined;
107
+ } & {
108
+ _id: import("mongoose").Types.ObjectId;
109
+ } & {
110
+ __v: number;
111
+ }) | ({
112
+ object: import("@chevre/factory/lib/chevre/transaction/returnOrder").IObject;
113
+ error?: any;
114
+ project: import("@chevre/factory/lib/chevre/transaction").IProject;
115
+ seller: import("@chevre/factory/lib/chevre/transaction").ISeller;
116
+ typeOf: factory.transactionType.ReturnOrder;
117
+ expires: Date;
118
+ result?: import("@chevre/factory/lib/chevre/transaction/returnOrder").IResult | undefined;
119
+ startDate: Date;
120
+ endDate?: Date | undefined;
121
+ agent: import("@chevre/factory/lib/chevre/transaction").IAgent;
122
+ recipient?: undefined;
123
+ status: factory.transactionStatusType;
124
+ tasksExportAction?: import("@chevre/factory/lib/chevre/transaction").ITasksExportAction | undefined;
125
+ potentialActions?: import("@chevre/factory/lib/chevre/transaction/returnOrder").IPotentialActions | undefined;
126
+ } & {
127
+ _id: import("mongoose").Types.ObjectId;
128
+ } & {
129
+ __v: number;
130
+ }))) | null>;
131
+ }
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdminTransactionRepo = void 0;
4
+ const transaction_1 = require("../eventEmitter/transaction");
5
+ const factory_1 = require("../factory");
6
+ const settings_1 = require("../settings");
7
+ const transaction_2 = require("./mongoose/schemas/transaction");
8
+ /**
9
+ * 取引管理リポジトリ
10
+ */
11
+ class AdminTransactionRepo {
12
+ transactionModel;
13
+ constructor(connection) {
14
+ this.transactionModel = connection.model(transaction_2.modelName, (0, transaction_2.createSchema)());
15
+ }
16
+ async countPotentiallyExportTasks(params) {
17
+ const { endDate, limit } = params;
18
+ const endDateLt = endDate?.$lt;
19
+ if (!(endDateLt instanceof Date)) {
20
+ throw new factory_1.factory.errors.Argument('endDate.$lt', 'must be Date');
21
+ }
22
+ const query = this.transactionModel.countDocuments({
23
+ status: {
24
+ $in: [
25
+ factory_1.factory.transactionStatusType.Canceled,
26
+ factory_1.factory.transactionStatusType.Confirmed,
27
+ factory_1.factory.transactionStatusType.Expired
28
+ ]
29
+ },
30
+ 'tasksExportAction.actionStatus': {
31
+ $exists: true,
32
+ $eq: factory_1.factory.actionStatusType.PotentialActionStatus
33
+ },
34
+ endDate: { $exists: true, $lt: endDateLt }
35
+ });
36
+ if (typeof limit === 'number' && limit >= 0) {
37
+ query.limit(limit);
38
+ }
39
+ const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
40
+ .exec();
41
+ return { count };
42
+ }
43
+ /**
44
+ * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
45
+ * PotentialActionStatusに変更する
46
+ * 2025-03-10~
47
+ */
48
+ async reExportAction(params) {
49
+ const { startDate } = params;
50
+ if (!(startDate.$lt instanceof Date)) {
51
+ throw new factory_1.factory.errors.Argument('startDate.$lt', 'must be Date');
52
+ }
53
+ return this.transactionModel.updateMany({
54
+ 'tasksExportAction.actionStatus': {
55
+ $exists: true,
56
+ $eq: factory_1.factory.actionStatusType.ActiveActionStatus
57
+ },
58
+ 'tasksExportAction.startDate': {
59
+ $exists: true,
60
+ $lt: startDate.$lt
61
+ }
62
+ }, {
63
+ $set: {
64
+ tasksExportAction: {
65
+ actionStatus: factory_1.factory.actionStatusType.PotentialActionStatus
66
+ }
67
+ }
68
+ })
69
+ .exec();
70
+ }
71
+ // /**
72
+ // * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
73
+ // */
74
+ // public async exportTasksMany(params: {
75
+ // now: Date;
76
+ // delayInSeconds: number;
77
+ // status: {
78
+ // $in: factory.transactionStatusType[];
79
+ // };
80
+ // limit: number;
81
+ // }) {
82
+ // const delayedTransactions = await this.transactionModel.find({
83
+ // status: { $in: params.status.$in },
84
+ // 'tasksExportAction.actionStatus': {
85
+ // $exists: true,
86
+ // $eq: factory.actionStatusType.PotentialActionStatus
87
+ // },
88
+ // endDate: {
89
+ // $exists: true,
90
+ // $lt: moment(params.now)
91
+ // .add(-params.delayInSeconds, 'seconds')
92
+ // .toDate()
93
+ // }
94
+ // })
95
+ // .select({
96
+ // _id: 0,
97
+ // id: { $toString: '$_id' },
98
+ // typeOf: 1,
99
+ // status: 1
100
+ // })
101
+ // .limit(params.limit)
102
+ // .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
103
+ // .lean<Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'status' | 'typeOf'>[]>()
104
+ // .exec();
105
+ // if (delayedTransactions.length > 0) {
106
+ // delayedTransactions.forEach((delayedTransaction) => {
107
+ // transactionEventEmitter.emitTransactionStatusChanged({
108
+ // id: delayedTransaction.id,
109
+ // typeOf: delayedTransaction.typeOf,
110
+ // status: delayedTransaction.status
111
+ // });
112
+ // });
113
+ // }
114
+ // return delayedTransactions;
115
+ // }
116
+ /**
117
+ * add(2025-03-13~)
118
+ */
119
+ async countPotentiallyExpired(params) {
120
+ const { expires, limit } = params;
121
+ const query = this.transactionModel.countDocuments({
122
+ status: { $eq: factory_1.factory.transactionStatusType.InProgress },
123
+ expires: { $lt: expires.$lt }
124
+ });
125
+ if (typeof limit === 'number' && limit >= 0) {
126
+ query.limit(limit);
127
+ }
128
+ const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
129
+ .exec();
130
+ return { count };
131
+ }
132
+ /**
133
+ * add(2025-03-03~)
134
+ */
135
+ async makeOneExpiredIfExists(params) {
136
+ const endDate = new Date();
137
+ const sort = {
138
+ expires: factory_1.factory.sortType.Ascending
139
+ };
140
+ const doc = await this.transactionModel.findOneAndUpdate({
141
+ status: { $eq: factory_1.factory.transactionStatusType.InProgress },
142
+ expires: { $lt: params.expires.$lt }
143
+ }, {
144
+ status: factory_1.factory.transactionStatusType.Expired,
145
+ endDate
146
+ }, {
147
+ new: true,
148
+ projection: {
149
+ _id: 0,
150
+ id: { $toString: '$_id' },
151
+ typeOf: 1
152
+ }
153
+ })
154
+ .sort(sort)
155
+ .lean()
156
+ .exec();
157
+ if (doc === null) {
158
+ // no op
159
+ return;
160
+ }
161
+ else {
162
+ transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
163
+ id: doc.id,
164
+ typeOf: doc.typeOf,
165
+ status: factory_1.factory.transactionStatusType.Expired
166
+ });
167
+ return doc;
168
+ }
169
+ }
170
+ // /**
171
+ // * 取引を期限切れにする
172
+ // */
173
+ // public async makeExpired(params: {
174
+ // expires: { $lt: Date };
175
+ // limit: number; // add limit(2025-02-27~)
176
+ // }): Promise<Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'typeOf'>[]> {
177
+ // if (typeof params.limit !== 'number' || params.limit === 0) {
178
+ // throw new factory.errors.ArgumentNull('limit');
179
+ // }
180
+ // const sort: { [key in keyof factory.transaction.ITransaction<factory.transactionType>]?: factory.sortType } = {
181
+ // expires: factory.sortType.Ascending
182
+ // };
183
+ // // IDをemitしたいのでまずリスト検索(2023-04-27~)
184
+ // const expiringTransactions =
185
+ // await this.transactionModel.find({
186
+ // status: { $eq: factory.transactionStatusType.InProgress },
187
+ // expires: { $lt: params.expires.$lt }
188
+ // })
189
+ // .select({
190
+ // _id: 0,
191
+ // id: { $toString: '$_id' },
192
+ // typeOf: 1
193
+ // })
194
+ // .limit(params.limit)
195
+ // .sort(sort) // sort(2025-03-03~)
196
+ // .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
197
+ // .lean<Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'typeOf'>[]>()
198
+ // .exec();
199
+ // if (expiringTransactions.length > 0) {
200
+ // // ステータスと期限を見て更新
201
+ // await this.transactionModel.updateMany(
202
+ // {
203
+ // _id: { $in: expiringTransactions.map((t) => t.id) },
204
+ // status: { $eq: factory.transactionStatusType.InProgress },
205
+ // expires: { $lt: params.expires.$lt }
206
+ // },
207
+ // {
208
+ // status: factory.transactionStatusType.Expired,
209
+ // endDate: new Date()
210
+ // }
211
+ // )
212
+ // .exec();
213
+ // expiringTransactions.forEach((expiringTransaction) => {
214
+ // transactionEventEmitter.emitTransactionStatusChanged({
215
+ // id: expiringTransaction.id,
216
+ // typeOf: expiringTransaction.typeOf,
217
+ // status: factory.transactionStatusType.Expired
218
+ // });
219
+ // });
220
+ // }
221
+ // return expiringTransactions;
222
+ // }
223
+ async findByIdAndDelete(params) {
224
+ await this.transactionModel.findByIdAndDelete(params.id)
225
+ .exec();
226
+ }
227
+ async unsetUnnecessaryFields(params) {
228
+ return this.transactionModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
229
+ .exec();
230
+ }
231
+ getCursor(conditions, projection, sort) {
232
+ return this.transactionModel.find(conditions, projection)
233
+ .sort({ startDate: (sort === factory_1.factory.sortType.Ascending) ? sort : factory_1.factory.sortType.Descending })
234
+ .cursor();
235
+ }
236
+ }
237
+ exports.AdminTransactionRepo = AdminTransactionRepo;
@@ -0,0 +1,39 @@
1
+ import type { Connection } from 'mongoose';
2
+ import { factory } from '../factory';
3
+ interface IAggregationByStatus {
4
+ transactionCount: number;
5
+ avgDuration: number;
6
+ maxDuration: number;
7
+ minDuration: number;
8
+ percentilesDuration: {
9
+ name: string;
10
+ value: number;
11
+ }[];
12
+ }
13
+ interface IStatus {
14
+ status: factory.transactionStatusType;
15
+ aggregation: IAggregationByStatus;
16
+ }
17
+ export interface IAggregatePlaceOrder {
18
+ statuses: IStatus[];
19
+ }
20
+ /**
21
+ * 取引集計リポジトリ
22
+ */
23
+ export declare class AggregateTransactionRepo {
24
+ private readonly transactionModel;
25
+ constructor(connection: Connection);
26
+ aggregatePlaceOrder(params: {
27
+ project?: {
28
+ id?: {
29
+ $ne?: string;
30
+ };
31
+ };
32
+ startFrom: Date;
33
+ startThrough: Date;
34
+ typeOf: factory.transactionType;
35
+ clientId?: string;
36
+ }): Promise<IAggregatePlaceOrder>;
37
+ private agggregateByStatus;
38
+ }
39
+ export {};
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AggregateTransactionRepo = void 0;
4
+ const factory_1 = require("../factory");
5
+ const transaction_1 = require("./mongoose/schemas/transaction");
6
+ /**
7
+ * 取引集計リポジトリ
8
+ */
9
+ class AggregateTransactionRepo {
10
+ transactionModel;
11
+ constructor(connection) {
12
+ this.transactionModel = connection.model(transaction_1.modelName, (0, transaction_1.createSchema)());
13
+ }
14
+ async aggregatePlaceOrder(params) {
15
+ const statuses = await Promise.all([
16
+ factory_1.factory.transactionStatusType.Confirmed,
17
+ factory_1.factory.transactionStatusType.Canceled,
18
+ factory_1.factory.transactionStatusType.Expired
19
+ ].map(async (transactionStatus) => {
20
+ const matchConditions = {
21
+ startDate: {
22
+ $gte: params.startFrom,
23
+ $lte: params.startThrough
24
+ },
25
+ typeOf: { $eq: params.typeOf },
26
+ status: { $eq: transactionStatus },
27
+ ...(typeof params.project?.id?.$ne === 'string')
28
+ ? { 'project.id': { $ne: params.project.id.$ne } }
29
+ : undefined,
30
+ ...(typeof params.clientId === 'string')
31
+ // customerIdentifierAll.push();
32
+ ? {
33
+ 'agent.identifier': {
34
+ $exists: true,
35
+ $all: [{ name: 'clientId', value: params.clientId }]
36
+ }
37
+ }
38
+ : undefined
39
+ };
40
+ return this.agggregateByStatus({ matchConditions, status: transactionStatus });
41
+ }));
42
+ return { statuses };
43
+ }
44
+ async agggregateByStatus(params) {
45
+ const matchConditions = params.matchConditions;
46
+ const transactionStatus = params.status;
47
+ const aggregations = await this.transactionModel.aggregate([
48
+ {
49
+ $match: matchConditions
50
+ },
51
+ {
52
+ $project: {
53
+ duration: { $subtract: ['$endDate', '$startDate'] },
54
+ status: '$status',
55
+ startDate: '$startDate',
56
+ endDate: '$endDate',
57
+ typeOf: '$typeOf'
58
+ }
59
+ },
60
+ {
61
+ $group: {
62
+ _id: '$typeOf',
63
+ transactionCount: { $sum: 1 },
64
+ maxDuration: { $max: '$duration' },
65
+ minDuration: { $min: '$duration' },
66
+ avgDuration: { $avg: '$duration' }
67
+ }
68
+ },
69
+ {
70
+ $project: {
71
+ _id: 0,
72
+ transactionCount: '$transactionCount',
73
+ avgDuration: '$avgDuration',
74
+ maxDuration: '$maxDuration',
75
+ minDuration: '$minDuration'
76
+ }
77
+ }
78
+ ])
79
+ .exec();
80
+ const percents = [50, 95, 99];
81
+ if (aggregations.length === 0) {
82
+ return {
83
+ status: transactionStatus,
84
+ aggregation: {
85
+ transactionCount: 0,
86
+ avgDuration: 0,
87
+ maxDuration: 0,
88
+ minDuration: 0,
89
+ percentilesDuration: percents.map((percent) => {
90
+ return {
91
+ name: String(percent),
92
+ value: 0
93
+ };
94
+ })
95
+ // totalPrice: 0,
96
+ // maxPrice: 0,
97
+ // minPrice: 0,
98
+ // avgPrice: 0
99
+ }
100
+ };
101
+ }
102
+ const ranks4percentile = percents.map((percentile) => {
103
+ return {
104
+ percentile,
105
+ rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
106
+ };
107
+ });
108
+ const aggregations2 = await this.transactionModel.aggregate([
109
+ {
110
+ $match: matchConditions
111
+ },
112
+ {
113
+ $project: {
114
+ duration: { $subtract: ['$endDate', '$startDate'] },
115
+ status: '$status',
116
+ startDate: '$startDate',
117
+ endDate: '$endDate',
118
+ typeOf: '$typeOf'
119
+ // result: '$result',
120
+ // price: {
121
+ // $cond: {
122
+ // if: { $isNumber: '$result.order.price' },
123
+ // then: '$result.order.price',
124
+ // else: 0
125
+ // }
126
+ // }
127
+ }
128
+ },
129
+ { $sort: { duration: 1 } },
130
+ {
131
+ $group: {
132
+ _id: '$typeOf',
133
+ durations: { $push: '$duration' }
134
+ // totalPrice: { $sum: '$price' },
135
+ // maxPrice: { $max: '$price' },
136
+ // minPrice: { $min: '$price' },
137
+ // avgPrice: { $avg: '$price' }
138
+ }
139
+ },
140
+ {
141
+ $project: {
142
+ _id: 0,
143
+ percentilesDuration: ranks4percentile.map((rank) => {
144
+ return {
145
+ name: String(rank.percentile),
146
+ value: { $arrayElemAt: ['$durations', rank.rank] }
147
+ };
148
+ })
149
+ // totalPrice: '$totalPrice',
150
+ // maxPrice: '$maxPrice',
151
+ // minPrice: '$minPrice',
152
+ // avgPrice: '$avgPrice'
153
+ }
154
+ }
155
+ ])
156
+ .exec();
157
+ return {
158
+ status: transactionStatus,
159
+ aggregation: {
160
+ ...aggregations[0],
161
+ ...aggregations2[0]
162
+ }
163
+ };
164
+ }
165
+ }
166
+ exports.AggregateTransactionRepo = AggregateTransactionRepo;
@@ -38,18 +38,17 @@ const schemaOptions = {
38
38
  }
39
39
  };
40
40
  const indexes = [
41
- // [ // discontinue(2024-08-07~)
42
- // { createdAt: 1 },
43
- // { name: 'searchByCreatedAt' }
44
- // ],
45
- // [
46
- // { updatedAt: 1 },
47
- // { name: 'searchByUpdatedAt' }
48
- // ],
49
41
  [
50
42
  { 'reservationFor.startDate': 1 },
51
- { name: 'searchByReservationForStartDate' }
43
+ {
44
+ name: 'ttlByReservationForStartDate', // support ttl index(2026-08-11~)
45
+ expireAfterSeconds: 16416000 // 190 days
46
+ }
52
47
  ],
48
+ // [
49
+ // { 'reservationFor.startDate': 1 },
50
+ // { name: 'searchByReservationForStartDate' }
51
+ // ],
53
52
  [
54
53
  { 'project.id': 1, 'reservationFor.startDate': 1 },
55
54
  { name: 'searchByProjectId' }
@@ -77,6 +77,13 @@ const schemaOptions = {
77
77
  }
78
78
  };
79
79
  const indexes = [
80
+ [
81
+ { endDate: 1 },
82
+ {
83
+ name: 'ttlByEndDate', // support ttl index(2026-08-11~)
84
+ expireAfterSeconds: 16416000 // 190 days
85
+ }
86
+ ],
80
87
  [
81
88
  { 'project.id': 1, startDate: 1 },
82
89
  {
@@ -44,6 +44,13 @@ const schemaOptions = {
44
44
  }
45
45
  };
46
46
  const indexes = [
47
+ [
48
+ { validThrough: 1 },
49
+ {
50
+ name: 'ttlByValidThrough', // support ttl index(2026-08-11~)
51
+ expireAfterSeconds: 0 // 0 days
52
+ }
53
+ ],
47
54
  [
48
55
  { validFrom: 1 },
49
56
  { name: 'validFrom' }
@@ -45,6 +45,13 @@ const schemaOptions = {
45
45
  }
46
46
  };
47
47
  const indexes = [
48
+ [
49
+ { expires: 1 },
50
+ {
51
+ name: 'ttlByExpires', // support ttl index(2026-08-11~)
52
+ expireAfterSeconds: 0 // 0 days
53
+ }
54
+ ],
48
55
  [
49
56
  { bookingTime: -1 },
50
57
  { name: 'bookingTime' }
@@ -113,10 +120,10 @@ const indexes = [
113
120
  }
114
121
  }
115
122
  ],
116
- [
117
- { expires: 1 },
118
- { name: 'deleteExpiredMany' }
119
- ]
123
+ // [
124
+ // { expires: 1 },
125
+ // { name: 'deleteExpiredMany' }
126
+ // ]
120
127
  ];
121
128
  exports.indexes = indexes;
122
129
  /**