Looking for assistance in converting an array of date strings to actual Date objects.
Here is the input data:
medicalData = [
{
name: 'Allergy',
status: 'Normal',
testDates: ['2023-07-02T13:21:29.643Z', '2023-07-03T13:21:29.644Z']
},
{
name: 'Asthma',
status: 'Deficient',
testDates: ['2023-08-02T13:21:29.643Z', '2023-08-03T13:21:29.644Z']
}
];
In my medical.service.ts file:
const result = await this.medicalRecordRepository.create({
medicalData: medicalData // need guidance on using new Date() here
});
Within medical.schema.ts:
class MedicalData {
@Prop()
name: string;
@Prop()
status: string;
@Prop()
testDates: [Date];
}
export class MedicalRecord extends Document {
@Prop()
medicalData: MedicalData[];
}
I want the testDates to be stored in the database as an array of dates, not strings.
Any valuable assistance would be greatly appreciated.