@chevre/domain 22.11.0-alpha.3 → 22.11.0-alpha.4
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.
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -8
- package/lib/chevre/repo/confirmationNumber.js +23 -27
- package/lib/chevre/repo/orderNumber.d.ts +0 -8
- package/lib/chevre/repo/orderNumber.js +23 -27
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +6 -14
- package/lib/chevre/repo/transactionNumber.d.ts +0 -8
- package/lib/chevre/repo/transactionNumber.js +23 -27
- package/package.json +1 -1
- package/example/src/chevre/transactionNumber/setUseMongo4confirmationNumberFrom.ts +0 -45
- package/example/src/chevre/transactionNumber/setUseMongo4orderNumberFrom.ts +0 -41
- package/example/src/chevre/transactionNumber/setUseMongo4transactionNumberFrom.ts +0 -41
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
2
|
import { RedisClientType } from 'redis';
|
|
3
|
-
import { ISetting } from './mongoose/schemas/setting';
|
|
4
3
|
/**
|
|
5
4
|
* 確認番号リポジトリ
|
|
6
5
|
*/
|
|
7
6
|
export declare class ConfirmationNumberRepo {
|
|
8
|
-
private readonly settingModel;
|
|
9
7
|
private readonly counterRepo;
|
|
10
8
|
constructor(params: {
|
|
11
9
|
redisClient: RedisClientType;
|
|
@@ -20,11 +18,5 @@ export declare class ConfirmationNumberRepo {
|
|
|
20
18
|
publish(params: {
|
|
21
19
|
orderDate: Date;
|
|
22
20
|
}): Promise<string>;
|
|
23
|
-
/**
|
|
24
|
-
* DB移行時のみに使用目的の設定更新
|
|
25
|
-
*/
|
|
26
|
-
setUseMongo4confirmationNumberFrom(params: {
|
|
27
|
-
useMongo4confirmationNumberFrom: Date;
|
|
28
|
-
}): Promise<Pick<ISetting, "useMongo4confirmationNumberFrom"> | null>;
|
|
29
21
|
private useMongoBySettings;
|
|
30
22
|
}
|
|
@@ -14,7 +14,7 @@ const cdigit = require("cdigit");
|
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
15
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
16
|
const fpe = require('node-fpe');
|
|
17
|
-
|
|
17
|
+
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
18
18
|
const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
|
|
19
19
|
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
20
20
|
const CONFIRMATION_NUMBER_MIN_LENGH = 4;
|
|
@@ -24,8 +24,8 @@ const TIMEZONE = 'Asia/Tokyo';
|
|
|
24
24
|
*/
|
|
25
25
|
class ConfirmationNumberRepo {
|
|
26
26
|
constructor(params) {
|
|
27
|
-
const { connection } = params;
|
|
28
|
-
this.settingModel = connection.model(
|
|
27
|
+
// const { connection } = params;
|
|
28
|
+
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
29
29
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
30
30
|
}
|
|
31
31
|
static alignDigits(params) {
|
|
@@ -99,31 +99,27 @@ class ConfirmationNumberRepo {
|
|
|
99
99
|
return ConfirmationNumberRepo.count2confirmationNumber({ count: incrReply });
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
setUseMongo4confirmationNumberFrom(params
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
102
|
+
// /**
|
|
103
|
+
// * DB移行時のみに使用目的の設定更新
|
|
104
|
+
// */
|
|
105
|
+
// public async setUseMongo4confirmationNumberFrom(params: {
|
|
106
|
+
// useMongo4confirmationNumberFrom: Date;
|
|
107
|
+
// }) {
|
|
108
|
+
// const { useMongo4confirmationNumberFrom } = params;
|
|
109
|
+
// return this.settingModel.findOneAndUpdate(
|
|
110
|
+
// { 'project.id': { $eq: '*' } },
|
|
111
|
+
// {
|
|
112
|
+
// $set: { useMongo4confirmationNumberFrom }
|
|
113
|
+
// },
|
|
114
|
+
// { projection: { _id: 0, useMongo4confirmationNumberFrom: 1 } }
|
|
115
|
+
// )
|
|
116
|
+
// .lean<Pick<ISetting, 'useMongo4confirmationNumberFrom'> | null>()
|
|
117
|
+
// .exec();
|
|
118
|
+
// }
|
|
119
|
+
// tslint:disable-next-line:prefer-function-over-method
|
|
120
|
+
useMongoBySettings(__) {
|
|
116
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
|
|
118
|
-
_id: 0,
|
|
119
|
-
useMongo4confirmationNumberFrom: 1
|
|
120
|
-
})
|
|
121
|
-
.lean()
|
|
122
|
-
.exec();
|
|
123
|
-
const useMongo4confirmationNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4confirmationNumberFrom;
|
|
124
|
-
return useMongo4confirmationNumberFrom instanceof Date
|
|
125
|
-
&& moment(params.orderDate)
|
|
126
|
-
.isSameOrAfter(moment(useMongo4confirmationNumberFrom));
|
|
122
|
+
return true;
|
|
127
123
|
});
|
|
128
124
|
}
|
|
129
125
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
2
|
import { RedisClientType } from 'redis';
|
|
3
|
-
import { ISetting } from './mongoose/schemas/setting';
|
|
4
3
|
/**
|
|
5
4
|
* 注文番号リポジトリ
|
|
6
5
|
*/
|
|
7
6
|
export declare class OrderNumberRepo {
|
|
8
|
-
private readonly settingModel;
|
|
9
7
|
private readonly counterRepo;
|
|
10
8
|
constructor(params: {
|
|
11
9
|
redisClient: RedisClientType;
|
|
@@ -23,11 +21,5 @@ export declare class OrderNumberRepo {
|
|
|
23
21
|
*/
|
|
24
22
|
orderDate: Date;
|
|
25
23
|
}): Promise<string>;
|
|
26
|
-
/**
|
|
27
|
-
* DB移行時のみに使用目的の設定更新
|
|
28
|
-
*/
|
|
29
|
-
setUseMongo4orderNumberFrom(params: {
|
|
30
|
-
useMongo4orderNumberFrom: Date;
|
|
31
|
-
}): Promise<Pick<ISetting, "useMongo4orderNumberFrom"> | null>;
|
|
32
24
|
private useMongoBySettings;
|
|
33
25
|
}
|
|
@@ -14,7 +14,7 @@ const cdigit = require("cdigit");
|
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
15
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
16
|
const fpe = require('node-fpe');
|
|
17
|
-
|
|
17
|
+
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
18
18
|
const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
|
|
19
19
|
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
20
20
|
const ORDER_NUMBER_SEPARATOR = '-';
|
|
@@ -23,8 +23,8 @@ const ORDER_NUMBER_SEPARATOR = '-';
|
|
|
23
23
|
*/
|
|
24
24
|
class OrderNumberRepo {
|
|
25
25
|
constructor(params) {
|
|
26
|
-
const { connection } = params;
|
|
27
|
-
this.settingModel = connection.model(
|
|
26
|
+
// const { connection } = params;
|
|
27
|
+
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
28
28
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
29
29
|
}
|
|
30
30
|
// private static createKey(params: {
|
|
@@ -90,31 +90,27 @@ class OrderNumberRepo {
|
|
|
90
90
|
return orderNumber;
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
setUseMongo4orderNumberFrom(params
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
93
|
+
// /**
|
|
94
|
+
// * DB移行時のみに使用目的の設定更新
|
|
95
|
+
// */
|
|
96
|
+
// public async setUseMongo4orderNumberFrom(params: {
|
|
97
|
+
// useMongo4orderNumberFrom: Date;
|
|
98
|
+
// }) {
|
|
99
|
+
// const { useMongo4orderNumberFrom } = params;
|
|
100
|
+
// return this.settingModel.findOneAndUpdate(
|
|
101
|
+
// { 'project.id': { $eq: '*' } },
|
|
102
|
+
// {
|
|
103
|
+
// $set: { useMongo4orderNumberFrom }
|
|
104
|
+
// },
|
|
105
|
+
// { projection: { _id: 0, useMongo4orderNumberFrom: 1 } }
|
|
106
|
+
// )
|
|
107
|
+
// .lean<Pick<ISetting, 'useMongo4orderNumberFrom'> | null>()
|
|
108
|
+
// .exec();
|
|
109
|
+
// }
|
|
110
|
+
// tslint:disable-next-line:prefer-function-over-method
|
|
111
|
+
useMongoBySettings(__) {
|
|
107
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
|
|
109
|
-
_id: 0,
|
|
110
|
-
useMongo4orderNumberFrom: 1
|
|
111
|
-
})
|
|
112
|
-
.lean()
|
|
113
|
-
.exec();
|
|
114
|
-
const useMongo4orderNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4orderNumberFrom;
|
|
115
|
-
return useMongo4orderNumberFrom instanceof Date
|
|
116
|
-
&& moment(params.orderDate)
|
|
117
|
-
.isSameOrAfter(moment(useMongo4orderNumberFrom));
|
|
113
|
+
return true;
|
|
118
114
|
});
|
|
119
115
|
}
|
|
120
116
|
}
|
|
@@ -14,7 +14,7 @@ const cdigit = require("cdigit");
|
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
15
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
16
|
const fpe = require('node-fpe');
|
|
17
|
-
|
|
17
|
+
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
18
18
|
const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
|
|
19
19
|
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
20
20
|
/**
|
|
@@ -22,8 +22,8 @@ const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
|
22
22
|
*/
|
|
23
23
|
class ServiceOutputIdentifierRepo {
|
|
24
24
|
constructor(params) {
|
|
25
|
-
const { connection } = params;
|
|
26
|
-
this.settingModel = connection.model(
|
|
25
|
+
// const { connection } = params;
|
|
26
|
+
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
27
27
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
28
28
|
}
|
|
29
29
|
// private static createKey(params: {
|
|
@@ -77,18 +77,10 @@ class ServiceOutputIdentifierRepo {
|
|
|
77
77
|
return identifier;
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
// tslint:disable-next-line:prefer-function-over-method
|
|
81
|
+
useMongoBySettings(__) {
|
|
81
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
|
|
83
|
-
_id: 0,
|
|
84
|
-
useMongo4transactionNumberFrom: 1
|
|
85
|
-
})
|
|
86
|
-
.lean()
|
|
87
|
-
.exec();
|
|
88
|
-
const useMongo4transactionNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4transactionNumberFrom;
|
|
89
|
-
return useMongo4transactionNumberFrom instanceof Date
|
|
90
|
-
&& moment(params.startDate)
|
|
91
|
-
.isSameOrAfter(moment(useMongo4transactionNumberFrom));
|
|
83
|
+
return true;
|
|
92
84
|
});
|
|
93
85
|
}
|
|
94
86
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
2
|
import { RedisClientType } from 'redis';
|
|
3
|
-
import { ISetting } from './mongoose/schemas/setting';
|
|
4
3
|
interface IPublishResult {
|
|
5
4
|
transactionNumber: string;
|
|
6
5
|
}
|
|
@@ -8,7 +7,6 @@ interface IPublishResult {
|
|
|
8
7
|
* 取引番号リポジトリ
|
|
9
8
|
*/
|
|
10
9
|
export declare class TransactionNumberRepo {
|
|
11
|
-
private readonly settingModel;
|
|
12
10
|
private readonly counterRepo;
|
|
13
11
|
constructor(params: {
|
|
14
12
|
redisClient: RedisClientType;
|
|
@@ -20,12 +18,6 @@ export declare class TransactionNumberRepo {
|
|
|
20
18
|
publishByTimestamp(params: {
|
|
21
19
|
startDate: Date;
|
|
22
20
|
}): Promise<IPublishResult>;
|
|
23
|
-
/**
|
|
24
|
-
* DB移行時のみに使用目的の設定更新
|
|
25
|
-
*/
|
|
26
|
-
setUseMongo4transactionNumberFrom(params: {
|
|
27
|
-
useMongo4transactionNumberFrom: Date;
|
|
28
|
-
}): Promise<Pick<ISetting, "useMongo4transactionNumberFrom"> | null>;
|
|
29
21
|
private useMongoBySettings;
|
|
30
22
|
}
|
|
31
23
|
export {};
|
|
@@ -14,7 +14,7 @@ const cdigit = require("cdigit");
|
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
15
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
16
|
const fpe = require('node-fpe');
|
|
17
|
-
|
|
17
|
+
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
18
18
|
const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
|
|
19
19
|
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
20
20
|
/**
|
|
@@ -22,8 +22,8 @@ const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
|
22
22
|
*/
|
|
23
23
|
class TransactionNumberRepo {
|
|
24
24
|
constructor(params) {
|
|
25
|
-
const { connection } = params;
|
|
26
|
-
this.settingModel = connection.model(
|
|
25
|
+
// const { connection } = params;
|
|
26
|
+
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
27
27
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
28
28
|
}
|
|
29
29
|
// private static createKey(params: {
|
|
@@ -77,31 +77,27 @@ class TransactionNumberRepo {
|
|
|
77
77
|
return { transactionNumber };
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
setUseMongo4transactionNumberFrom(params
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
80
|
+
// /**
|
|
81
|
+
// * DB移行時のみに使用目的の設定更新
|
|
82
|
+
// */
|
|
83
|
+
// public async setUseMongo4transactionNumberFrom(params: {
|
|
84
|
+
// useMongo4transactionNumberFrom: Date;
|
|
85
|
+
// }) {
|
|
86
|
+
// const { useMongo4transactionNumberFrom } = params;
|
|
87
|
+
// return this.settingModel.findOneAndUpdate(
|
|
88
|
+
// { 'project.id': { $eq: '*' } },
|
|
89
|
+
// {
|
|
90
|
+
// $set: { useMongo4transactionNumberFrom }
|
|
91
|
+
// },
|
|
92
|
+
// { projection: { _id: 0, useMongo4transactionNumberFrom: 1 } }
|
|
93
|
+
// )
|
|
94
|
+
// .lean<Pick<ISetting, 'useMongo4transactionNumberFrom'> | null>()
|
|
95
|
+
// .exec();
|
|
96
|
+
// }
|
|
97
|
+
// tslint:disable-next-line:prefer-function-over-method
|
|
98
|
+
useMongoBySettings(__) {
|
|
94
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
|
|
96
|
-
_id: 0,
|
|
97
|
-
useMongo4transactionNumberFrom: 1
|
|
98
|
-
})
|
|
99
|
-
.lean()
|
|
100
|
-
.exec();
|
|
101
|
-
const useMongo4transactionNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4transactionNumberFrom;
|
|
102
|
-
return useMongo4transactionNumberFrom instanceof Date
|
|
103
|
-
&& moment(params.startDate)
|
|
104
|
-
.isSameOrAfter(moment(useMongo4transactionNumberFrom));
|
|
100
|
+
return true;
|
|
105
101
|
});
|
|
106
102
|
}
|
|
107
103
|
}
|
package/package.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import * as redis from 'redis';
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
10
|
-
socket: {
|
|
11
|
-
port: Number(<string>process.env.REDIS_PORT),
|
|
12
|
-
host: <string>process.env.REDIS_HOST
|
|
13
|
-
},
|
|
14
|
-
password: <string>process.env.REDIS_KEY,
|
|
15
|
-
name: 'checkRedisKeyCount'
|
|
16
|
-
})
|
|
17
|
-
.on('error', (err) => {
|
|
18
|
-
// eslint-disable-next-line no-console
|
|
19
|
-
console.error('createDefaultRedisClient: client onError:', err);
|
|
20
|
-
// reject(err);
|
|
21
|
-
});
|
|
22
|
-
redisClient.connect();
|
|
23
|
-
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
24
|
-
|
|
25
|
-
async function main() {
|
|
26
|
-
const confirmationNumberRepo = await chevre.repository.ConfirmationNumber.createInstance({
|
|
27
|
-
redisClient,
|
|
28
|
-
connection: mongoose.connection
|
|
29
|
-
});
|
|
30
|
-
const result = await confirmationNumberRepo.setUseMongo4confirmationNumberFrom({
|
|
31
|
-
// useMongo4confirmationNumberFrom: moment('2025-05-22T23:50:00Z')
|
|
32
|
-
// .toDate(),
|
|
33
|
-
// useMongo4confirmationNumberFrom: moment('2025-05-25T15:00:00Z')
|
|
34
|
-
// .toDate()
|
|
35
|
-
useMongo4confirmationNumberFrom: moment('2025-05-31T15:00:00Z')
|
|
36
|
-
.toDate()
|
|
37
|
-
});
|
|
38
|
-
console.log(result);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
main()
|
|
42
|
-
.then(() => {
|
|
43
|
-
console.log('success!');
|
|
44
|
-
})
|
|
45
|
-
.catch(console.error);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import * as redis from 'redis';
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
10
|
-
socket: {
|
|
11
|
-
port: Number(<string>process.env.REDIS_PORT),
|
|
12
|
-
host: <string>process.env.REDIS_HOST
|
|
13
|
-
},
|
|
14
|
-
password: <string>process.env.REDIS_KEY,
|
|
15
|
-
name: 'checkRedisKeyCount'
|
|
16
|
-
})
|
|
17
|
-
.on('error', (err) => {
|
|
18
|
-
// eslint-disable-next-line no-console
|
|
19
|
-
console.error('createDefaultRedisClient: client onError:', err);
|
|
20
|
-
// reject(err);
|
|
21
|
-
});
|
|
22
|
-
redisClient.connect();
|
|
23
|
-
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
24
|
-
|
|
25
|
-
async function main() {
|
|
26
|
-
const orderNumberRepo = await chevre.repository.OrderNumber.createInstance({
|
|
27
|
-
redisClient,
|
|
28
|
-
connection: mongoose.connection
|
|
29
|
-
});
|
|
30
|
-
const result = await orderNumberRepo.setUseMongo4orderNumberFrom({
|
|
31
|
-
useMongo4orderNumberFrom: moment('2025-06-03T05:00:00Z')
|
|
32
|
-
.toDate()
|
|
33
|
-
});
|
|
34
|
-
console.log(result);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
main()
|
|
38
|
-
.then(() => {
|
|
39
|
-
console.log('success!');
|
|
40
|
-
})
|
|
41
|
-
.catch(console.error);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import * as redis from 'redis';
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
10
|
-
socket: {
|
|
11
|
-
port: Number(<string>process.env.REDIS_PORT),
|
|
12
|
-
host: <string>process.env.REDIS_HOST
|
|
13
|
-
},
|
|
14
|
-
password: <string>process.env.REDIS_KEY,
|
|
15
|
-
name: 'checkRedisKeyCount'
|
|
16
|
-
})
|
|
17
|
-
.on('error', (err) => {
|
|
18
|
-
// eslint-disable-next-line no-console
|
|
19
|
-
console.error('createDefaultRedisClient: client onError:', err);
|
|
20
|
-
// reject(err);
|
|
21
|
-
});
|
|
22
|
-
redisClient.connect();
|
|
23
|
-
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
24
|
-
|
|
25
|
-
async function main() {
|
|
26
|
-
const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance({
|
|
27
|
-
redisClient,
|
|
28
|
-
connection: mongoose.connection
|
|
29
|
-
});
|
|
30
|
-
const result = await transactionNumberRepo.setUseMongo4transactionNumberFrom({
|
|
31
|
-
useMongo4transactionNumberFrom: moment('2025-06-05T22:45:00Z')
|
|
32
|
-
.toDate()
|
|
33
|
-
});
|
|
34
|
-
console.log(result);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
main()
|
|
38
|
-
.then(() => {
|
|
39
|
-
console.log('success!');
|
|
40
|
-
})
|
|
41
|
-
.catch(console.error);
|