async findById(id: string | string[]) {
let res
try {
if (Array.isArray(id)) {
res=await this.dataModel.find({ _id: { $in: id } })
} else {
res=await this.dataModel.findById(id)
}
} catch (error) {
throw new HttpException(error, HttpStatus.INTERNAL_SERVER_ERROR)
}
return res;
}
async findById(id: string | string[]) {
let res
try {
if (Array.isArray(id)) {
res=await this.dataModel.find({ _id: { $in: id } })
} else {
res=await this.dataModel.findById(id)
}
} catch (error) {
throw new HttpException(error, HttpStatus.INTERNAL_SERVER_ERROR)
}
return res;
}
async copyDataModal(dataModel: CopyDataModelDto) {
let res
try {
const { id }=dataModel
const modalData=await this.findById(id)
if (modalData) {
modalData.props=(modalData.props || []).map((ele: any)=> {
return dataMasking(ele, [‘_id’])
})
const addData=dataMasking({ …modalData, …dataModel }, [‘_id’, ‘id’, ‘__v’])
// res=await this.add(addData)
res=addData
}
} catch (error) {
throw new HttpException(error, HttpStatus.INTERNAL_SERVER_ERROR)
}
return res
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。