|
|
@@ -1,7 +1,6 @@
|
|
|
import { Model, Schema, HydratedDocument } from 'mongoose';
|
|
|
|
|
|
import { ITransferKey } from '~/interfaces/transfer-key';
|
|
|
-import { TransferKey } from '~/utils/vo/transfer-key';
|
|
|
|
|
|
import loggerFactory from '../../utils/logger';
|
|
|
import { getOrCreateModel } from '../util/mongoose-utils';
|
|
|
@@ -17,6 +16,7 @@ type TransferKeyModel = Model<ITransferKey, any, ITransferKeyMethods>;
|
|
|
const schema = new Schema<ITransferKey, TransferKeyModel, ITransferKeyMethods>({
|
|
|
expireAt: { type: Date, default: () => new Date(), expires: '30m' },
|
|
|
keyString: { type: String, unique: true }, // original key string
|
|
|
+ key: { type: String, unique: true },
|
|
|
}, {
|
|
|
timestamps: {
|
|
|
createdAt: true,
|
|
|
@@ -24,11 +24,6 @@ const schema = new Schema<ITransferKey, TransferKeyModel, ITransferKeyMethods>({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
-// Virtuals
|
|
|
-schema.virtual('key').get(function() {
|
|
|
- return TransferKey.parse(this.keyString).key;
|
|
|
-});
|
|
|
-
|
|
|
schema.statics.findOneActiveTransferKey = async function(key: string): Promise<HydratedDocument<ITransferKey, ITransferKeyMethods> | null> {
|
|
|
return this.findOne({ key });
|
|
|
};
|