fix: config merge
This commit is contained in:
@@ -60,8 +60,10 @@ export class UrlDto {
|
||||
class MailOption {
|
||||
@IsInt()
|
||||
@Transform(({ value: val }) => parseInt(val))
|
||||
@IsOptional()
|
||||
port: number
|
||||
@IsUrl({ require_protocol: false })
|
||||
@IsOptional()
|
||||
host: string
|
||||
}
|
||||
export class MailOptionsDto {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
} from '@nestjs/common'
|
||||
import { DocumentType, ReturnModelType } from '@typegoose/typegoose'
|
||||
import { BeAnObject } from '@typegoose/typegoose/lib/types'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { cloneDeep, merge } from 'lodash'
|
||||
import { LeanDocument } from 'mongoose'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { API_VERSION } from '~/app.config'
|
||||
@@ -121,7 +121,7 @@ export class ConfigsService {
|
||||
public async patch<T extends keyof IConfig>(key: T, data: IConfig[T]) {
|
||||
await this.optionModel.updateOne(
|
||||
{ name: key as string },
|
||||
{ value: { ...this.config[key], ...data } },
|
||||
{ value: merge(this.config[key], data) },
|
||||
{ upsert: true, omitUndefined: true },
|
||||
)
|
||||
const newData = (await this.optionModel.findOne({ name: key as string }))
|
||||
|
||||
Reference in New Issue
Block a user