@@ -448,6 +448,12 @@ def __real_find_with_cursor(
448
448
filter = BSON .encode (filter , codec_options = self .codec_options )
449
449
450
450
as_class = kwargs .get ("as_class" )
451
+ if as_class is not None :
452
+ warnings .warn (
453
+ "as_class argument of will be removed in the next version of TxMongo. Please use document_class parameter of codec_options." ,
454
+ DeprecationWarning ,
455
+ )
456
+
451
457
proto = self ._database .connection .getprotocol ()
452
458
453
459
def after_connection (protocol ):
@@ -591,6 +597,11 @@ def count(self, filter=None, **kwargs):
591
597
592
598
@timeout
593
599
def group (self , keys , initial , reduce , condition = None , finalize = None , ** kwargs ):
600
+ warnings .warn (
601
+ "Collection.group() method will be removed in the next version of TxMongo. Please use aggregate() or map_reduce()." ,
602
+ DeprecationWarning ,
603
+ )
604
+
594
605
body = {
595
606
"ns" : self ._collection_name ,
596
607
"initial" : initial ,
@@ -674,6 +685,11 @@ def insert(self, docs, safe=None, flags=0, **kwargs):
674
685
:class:`Deferred` that fires with single ``_id`` field or a list of
675
686
``_id`` fields of inserted documents.
676
687
"""
688
+ warnings .warn (
689
+ "Collection.insert() method will be removed in the next version of TxMongo. Please use insert_one() or insert_many()." ,
690
+ DeprecationWarning ,
691
+ )
692
+
677
693
if isinstance (docs , dict ):
678
694
ids = docs .get ("_id" , ObjectId ())
679
695
docs ["_id" ] = ids
@@ -895,6 +911,10 @@ def update(
895
911
:class:`Deferred` that is called back when request is sent to
896
912
MongoDB or confirmed by MongoDB (depending on selected Write Concern).
897
913
"""
914
+ warnings .warn (
915
+ "Collection.update() method will be removed in the next version of TxMongo. Please use update_one(), update_many() or replace_one()." ,
916
+ DeprecationWarning ,
917
+ )
898
918
899
919
if not isinstance (spec , dict ):
900
920
raise TypeError ("TxMongo: spec must be an instance of dict." )
@@ -1071,6 +1091,12 @@ def on_ok(raw_response):
1071
1091
1072
1092
@timeout
1073
1093
def save (self , doc , safe = None , ** kwargs ):
1094
+ warnings .warn (
1095
+ "Collection.save() method will be removed in the next version of TxMongo. "
1096
+ "Please use insert_one() or replace_one()." ,
1097
+ DeprecationWarning ,
1098
+ )
1099
+
1074
1100
if not isinstance (doc , dict ):
1075
1101
raise TypeError (
1076
1102
"TxMongo: cannot save objects of type {0}" .format (type (doc ))
@@ -1083,6 +1109,11 @@ def save(self, doc, safe=None, **kwargs):
1083
1109
1084
1110
@timeout
1085
1111
def remove (self , spec , safe = None , single = False , flags = 0 , ** kwargs ):
1112
+ warnings .warn (
1113
+ "Collection.remove() method will be removed in the next version of TxMongo. Please use delete_one() or delete_many()." ,
1114
+ DeprecationWarning ,
1115
+ )
1116
+
1086
1117
if isinstance (spec , ObjectId ):
1087
1118
spec = SON (dict (_id = spec ))
1088
1119
if not isinstance (spec , dict ):
@@ -1318,6 +1349,12 @@ def on_ok(raw):
1318
1349
1319
1350
@timeout
1320
1351
def find_and_modify (self , query = None , update = None , upsert = False , ** kwargs ):
1352
+ warnings .warn (
1353
+ "Collection.find_and_modify() method will be removed in the next version of TxMongo. "
1354
+ "Please use find_one_and_update(), find_one_and_replace() or find_one_and_delete()." ,
1355
+ DeprecationWarning ,
1356
+ )
1357
+
1321
1358
no_obj_error = "No matching object found"
1322
1359
1323
1360
if not update and not kwargs .get ("remove" , None ):
0 commit comments