@@ -706,6 +706,9 @@ declare module 'mongoose' {
706706 [ K in keyof T ] : FlattenProperty < T [ K ] > ;
707707 } ;
708708
709+ /**
710+ * Converts any Buffer properties into mongodb.Binary instances, which is what `lean()` returns
711+ */
709712 export type BufferToBinary < T > = T extends TreatAsPrimitives ? T : T extends Record < string , any > ? {
710713 [ K in keyof T ] : T [ K ] extends Buffer
711714 ? mongodb . Binary
@@ -718,6 +721,9 @@ declare module 'mongoose' {
718721 : BufferToBinary < T [ K ] > ;
719722 } : T ;
720723
724+ /**
725+ * Converts any Buffer properties into { type: 'buffer', data: [1, 2, 3] } format for JSON serialization
726+ */
721727 export type BufferToJSON < T > = T extends TreatAsPrimitives ? T : T extends Record < string , any > ? {
722728 [ K in keyof T ] : T [ K ] extends Buffer
723729 ? { type : 'buffer' , data : number [ ] }
@@ -730,6 +736,9 @@ declare module 'mongoose' {
730736 : BufferToBinary < T [ K ] > ;
731737 } : T ;
732738
739+ /**
740+ * Converts any ObjectId properties into strings for JSON serialization
741+ */
733742 export type ObjectIdToString < T > = T extends TreatAsPrimitives ? T : T extends Record < string , any > ? {
734743 [ K in keyof T ] : T [ K ] extends mongodb . ObjectId
735744 ? string
@@ -742,6 +751,9 @@ declare module 'mongoose' {
742751 : ObjectIdToString < T [ K ] > ;
743752 } : T ;
744753
754+ /**
755+ * Converts any Date properties into strings for JSON serialization
756+ */
745757 export type DateToString < T > = T extends TreatAsPrimitives ? T : T extends Record < string , any > ? {
746758 [ K in keyof T ] : T [ K ] extends NativeDate
747759 ? string
@@ -754,6 +766,9 @@ declare module 'mongoose' {
754766 : DateToString < T [ K ] > ;
755767 } : T ;
756768
769+ /**
770+ * Converts any Mongoose subdocuments (single nested or doc arrays) into POJO equivalents
771+ */
757772 export type SubdocsToPOJOs < T > = T extends TreatAsPrimitives ? T : T extends Record < string , any > ? {
758773 [ K in keyof T ] : T [ K ] extends NativeDate
759774 ? string
0 commit comments