I'm trying to have a mixed type for my schema - my type is
{type: value: {type: Number}, label: {type: String} }
I want to transform value being saved with setter function but the SETTER returns an empty object. {}
@Prop({type: {value: {type: Number}, label: {type: String}, minimize: false, set: (v: any) => console.log(v)})
custom_id: {
value: {type: number},
label: {type: string}
};
Also tried with schema type
@Prop({type: {value: {type: Number}, label: {type: String}, minimize: false, set: (v: any) => console.log(v)})
custom_id:{
value: number,
label: string
};
@Schema()
class CustomId {
@Prop({type: Number})
value: number;
@Prop({type: String})
label: string;
}
export const CustomIdSchema = SchemaFactory.createForClass(CustomId);
@Prop({type: CustomIdSchema, minimize: false, set: (v: any) => console.log(v)})
custom_id: CustomId;
It's worth nothing im populating the field via a plugin
schema.plugin(AutoIncrement, {inc_field: 'custom_id.value', inc_amount: 0o1, start_seq: 0o1});
The value gets saved successfully but i want to add a label to it