@@ -67,6 +67,47 @@ schema.pre('init', function() {
67
67
expectType < HydratedDocument < IDocument > > ( this ) ;
68
68
} ) ;
69
69
70
+ schema . post ( 'init' , function ( res ) {
71
+ expectType < HydratedDocument < IDocument > > ( this ) ;
72
+ expectNotType < Query < any , any > > ( res ) ;
73
+ } ) ;
74
+
75
+ schema . pre ( 'init' , { document : true , query : false } , function ( ) {
76
+ expectType < HydratedDocument < IDocument > > ( this ) ;
77
+ } ) ;
78
+
79
+ schema . post ( 'init' , { document : true , query : false } , function ( res ) {
80
+ expectType < HydratedDocument < IDocument > > ( this ) ;
81
+ expectNotType < Query < any , any > > ( res ) ;
82
+ } ) ;
83
+
84
+ schema . pre ( 'init' , { document : true , query : true } , function ( ) {
85
+ expectType < HydratedDocument < IDocument > > ( this ) ;
86
+ } ) ;
87
+
88
+ schema . post ( 'init' , { document : true , query : true } , function ( res ) {
89
+ expectType < HydratedDocument < IDocument > > ( this ) ;
90
+ expectNotType < Query < any , any > > ( res ) ;
91
+ } ) ;
92
+
93
+ schema . pre ( 'init' , { document : false , query : true } , function ( ) {
94
+ expectType < never > ( this ) ;
95
+ } ) ;
96
+
97
+ schema . post ( 'init' , { document : false , query : true } , function ( res ) {
98
+ expectType < never > ( this ) ;
99
+ expectNotType < Query < any , any > > ( res ) ;
100
+ } ) ;
101
+
102
+ schema . pre ( 'init' , { document : false , query : false } , function ( ) {
103
+ expectType < never > ( this ) ;
104
+ } ) ;
105
+
106
+ schema . post ( 'init' , { document : false , query : false } , function ( res ) {
107
+ expectType < never > ( this ) ;
108
+ expectNotType < Query < any , any > > ( res ) ;
109
+ } ) ;
110
+
70
111
schema . pre ( 'estimatedDocumentCount' , function ( ) {
71
112
expectType < Query < any , any > > ( this ) ;
72
113
} ) ;
@@ -652,6 +693,51 @@ schema.post('deleteOne', { document: false, query: false }, function(res) {
652
693
expectNotType < Query < any , any > > ( res ) ;
653
694
} ) ;
654
695
696
+ schema . pre ( [ 'save' , 'init' ] , function ( ) {
697
+ expectType < HydratedDocument < IDocument > > ( this ) ;
698
+ } ) ;
699
+
700
+ schema . post ( [ 'save' , 'init' ] , function ( res ) {
701
+ expectType < HydratedDocument < IDocument > > ( this ) ;
702
+ expectNotType < Query < any , any > > ( res ) ;
703
+ } ) ;
704
+
705
+ schema . pre ( [ 'save' , 'init' ] , { document : true , query : false } , function ( ) {
706
+ expectType < HydratedDocument < IDocument > > ( this ) ;
707
+ } ) ;
708
+
709
+ schema . post ( [ 'save' , 'init' ] , { document : true , query : false } , function ( res ) {
710
+ expectType < HydratedDocument < IDocument > > ( this ) ;
711
+ expectNotType < Query < any , any > > ( res ) ;
712
+ } ) ;
713
+
714
+ schema . pre ( [ 'save' , 'init' ] , { document : true , query : true } , function ( ) {
715
+ expectType < HydratedDocument < IDocument > > ( this ) ;
716
+ } ) ;
717
+
718
+ schema . post ( [ 'save' , 'init' ] , { document : true , query : true } , function ( res ) {
719
+ expectType < HydratedDocument < IDocument > > ( this ) ;
720
+ expectNotType < Query < any , any > > ( res ) ;
721
+ } ) ;
722
+
723
+ schema . pre ( [ 'save' , 'init' ] , { document : false , query : true } , function ( ) {
724
+ expectType < never > ( this ) ;
725
+ } ) ;
726
+
727
+ schema . post ( [ 'save' , 'init' ] , { document : false , query : true } , function ( res ) {
728
+ expectType < never > ( this ) ;
729
+ expectNotType < Query < any , any > > ( res ) ;
730
+ } ) ;
731
+
732
+ schema . pre ( [ 'save' , 'init' ] , { document : false , query : false } , function ( ) {
733
+ expectType < never > ( this ) ;
734
+ } ) ;
735
+
736
+ schema . post ( [ 'save' , 'init' ] , { document : false , query : false } , function ( res ) {
737
+ expectType < never > ( this ) ;
738
+ expectNotType < Query < any , any > > ( res ) ;
739
+ } ) ;
740
+
655
741
schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' ] , function ( ) {
656
742
expectType < Query < any , any > > ( this ) ;
657
743
} ) ;
@@ -742,137 +828,137 @@ schema.post(['estimatedDocumentCount', 'countDocuments', 'deleteMany', 'distinct
742
828
expectNotType < Query < any , any > > ( res ) ;
743
829
} ) ;
744
830
745
- schema . pre ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , function ( ) {
831
+ schema . pre ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , function ( ) {
746
832
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
747
833
} ) ;
748
834
749
- schema . post ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , function ( res ) {
835
+ schema . post ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , function ( res ) {
750
836
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
751
837
expectNotType < Query < any , any > > ( res ) ;
752
838
} ) ;
753
839
754
- schema . pre ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( ) {
840
+ schema . pre ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( ) {
755
841
expectType < Query < any , any > > ( this ) ;
756
842
} ) ;
757
843
758
- schema . post ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( res ) {
844
+ schema . post ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( res ) {
759
845
expectType < Query < any , any > > ( this ) ;
760
846
expectNotType < Query < any , any > > ( res ) ;
761
847
} ) ;
762
848
763
- schema . pre ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( ) {
849
+ schema . pre ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( ) {
764
850
expectType < HydratedDocument < IDocument > > ( this ) ;
765
851
} ) ;
766
852
767
- schema . post ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( res ) {
853
+ schema . post ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( res ) {
768
854
expectType < HydratedDocument < IDocument > > ( this ) ;
769
855
expectNotType < Query < any , any > > ( res ) ;
770
856
} ) ;
771
857
772
- schema . pre ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( ) {
858
+ schema . pre ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( ) {
773
859
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
774
860
} ) ;
775
861
776
- schema . post ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( res ) {
862
+ schema . post ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( res ) {
777
863
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
778
864
expectNotType < Query < any , any > > ( res ) ;
779
865
} ) ;
780
866
781
- schema . pre ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( ) {
867
+ schema . pre ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( ) {
782
868
expectType < never > ( this ) ;
783
869
} ) ;
784
870
785
- schema . post ( [ 'estimatedDocumentCount ' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( res ) {
871
+ schema . post ( [ 'save ' , 'init ' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( res ) {
786
872
expectType < never > ( this ) ;
787
873
expectNotType < Query < any , any > > ( res ) ;
788
874
} ) ;
789
875
790
- schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , function ( ) {
876
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , function ( ) {
791
877
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
792
878
} ) ;
793
879
794
- schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , function ( res ) {
880
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , function ( res ) {
795
881
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
796
882
expectNotType < Query < any , any > > ( res ) ;
797
883
} ) ;
798
884
799
- schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( ) {
885
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( ) {
800
886
expectType < Query < any , any > > ( this ) ;
801
887
} ) ;
802
888
803
- schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( res ) {
889
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( res ) {
804
890
expectType < Query < any , any > > ( this ) ;
805
891
expectNotType < Query < any , any > > ( res ) ;
806
892
} ) ;
807
893
808
- schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( ) {
894
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( ) {
809
895
expectType < HydratedDocument < IDocument > > ( this ) ;
810
896
} ) ;
811
897
812
- schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( res ) {
898
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( res ) {
813
899
expectType < HydratedDocument < IDocument > > ( this ) ;
814
900
expectNotType < Query < any , any > > ( res ) ;
815
901
} ) ;
816
902
817
- schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( ) {
903
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( ) {
818
904
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
819
905
} ) ;
820
906
821
- schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( res ) {
907
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( res ) {
822
908
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
823
909
expectNotType < Query < any , any > > ( res ) ;
824
910
} ) ;
825
911
826
- schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( ) {
912
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( ) {
827
913
expectType < never > ( this ) ;
828
914
} ) ;
829
915
830
- schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'save' , ' updateOne', 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( res ) {
916
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( res ) {
831
917
expectType < never > ( this ) ;
832
918
expectNotType < Query < any , any > > ( res ) ;
833
919
} ) ;
834
920
835
- schema . pre ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , function ( ) {
921
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , function ( ) {
836
922
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
837
923
} ) ;
838
924
839
- schema . post ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , function ( res ) {
925
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , function ( res ) {
840
926
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
841
927
expectNotType < Query < any , any > > ( res ) ;
842
928
} ) ;
843
929
844
- schema . pre ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( ) {
930
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( ) {
845
931
expectType < Query < any , any > > ( this ) ;
846
932
} ) ;
847
933
848
- schema . post ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( res ) {
934
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : true } , function ( res ) {
849
935
expectType < Query < any , any > > ( this ) ;
850
936
expectNotType < Query < any , any > > ( res ) ;
851
937
} ) ;
852
938
853
- schema . pre ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( ) {
939
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( ) {
854
940
expectType < HydratedDocument < IDocument > > ( this ) ;
855
941
} ) ;
856
942
857
- schema . post ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( res ) {
943
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : false } , function ( res ) {
858
944
expectType < HydratedDocument < IDocument > > ( this ) ;
859
945
expectNotType < Query < any , any > > ( res ) ;
860
946
} ) ;
861
947
862
- schema . pre ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( ) {
948
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( ) {
863
949
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
864
950
} ) ;
865
951
866
- schema . post ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( res ) {
952
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : true , query : true } , function ( res ) {
867
953
expectType < Query < any , any > | HydratedDocument < IDocument > > ( this ) ;
868
954
expectNotType < Query < any , any > > ( res ) ;
869
955
} ) ;
870
956
871
- schema . pre ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( ) {
957
+ schema . pre ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( ) {
872
958
expectType < never > ( this ) ;
873
959
} ) ;
874
960
875
- schema . post ( [ 'save' , 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( res ) {
961
+ schema . post ( [ 'estimatedDocumentCount' , 'countDocuments' , 'deleteMany' , 'distinct' , 'find' , 'findOne' , 'findOneAndDelete' , 'findOneAndReplace' , 'findOneAndUpdate' , 'replaceOne' , 'updateMany' , ' save' , 'init ', 'updateOne' , 'deleteOne' , 'validate' ] , { document : false , query : false } , function ( res ) {
876
962
expectType < never > ( this ) ;
877
963
expectNotType < Query < any , any > > ( res ) ;
878
964
} ) ;
0 commit comments