Skip to content

Commit 68fbb50

Browse files
committed
update insert and save with new methods
1 parent 598d1d4 commit 68fbb50

File tree

4 files changed

+106
-9
lines changed

4 files changed

+106
-9
lines changed

.gitignore

+102-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,105 @@
1-
*~
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
23
*.py[cod]
3-
.DS*
4-
cover/
5-
dist/
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
611
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
741
.coverage
8-
*.egg*
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
cover/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Django stuff:
56+
*.log
57+
local_settings.py
58+
db.sqlite3
59+
60+
# Flask stuff:
61+
instance/
62+
.webassets-cache
63+
64+
# Scrapy stuff:
65+
.scrapy
66+
67+
# Sphinx documentation
68+
docs/_build/
69+
70+
# PyBuilder
71+
target/
72+
73+
# Jupyter Notebook
74+
.ipynb_checkpoints
75+
76+
# pyenv
77+
.python-version
78+
79+
# celery beat schedule file
80+
celerybeat-schedule
81+
82+
# SageMath parsed files
83+
*.sage.py
84+
85+
# Environments
86+
.env
87+
.venv
88+
env/
89+
venv/
90+
ENV/
91+
env.bak/
92+
venv.bak/
93+
94+
# Spyder project settings
95+
.spyderproject
96+
.spyproject
97+
98+
# Rope project settings
99+
.ropeproject
100+
101+
# mkdocs documentation
102+
/site
103+
104+
# mypy
105+
.mypy_cache/

nanomongo/document.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def insert(self, **kwargs):
378378
:meth:`~run_auto_updates()` and :meth:`~validate_all()` """
379379
self.run_auto_updates()
380380
self.validate_all()
381-
id_or_ids = self.get_collection().insert(self, **kwargs)
381+
id_or_ids = self.get_collection().insert_one(self, **kwargs)
382382
self.reset_diff()
383383
for field_name, field_value in self.items():
384384
if isinstance(field_value, dict): # cast dicts
@@ -412,7 +412,7 @@ def save(self, **kwargs):
412412
if not diff:
413413
self.reset_diff()
414414
return
415-
response = self.get_collection().update(query, diff, **kwargs)
415+
response = self.get_collection().update_one(query, diff, **kwargs)
416416
self.reset_diff()
417417
return response
418418

nanomongo/field.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class Field(object):
1313
"""Instances of this class is used to define field types and automatically
14-
create validators. Note that a Field definition has no value added::
14+
create validators::
1515
1616
field_name = Field(str, default='cheeseburger')
1717
foo = Field(datetime, auto_update=True)

test/test_document.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class Doc(BaseDocument):
265265
self.assertRaises(ValidationError, d.save) # _id manually set
266266
self.assertRaises(ValidationError, d.insert) # missing field moo
267267
d.moo = []
268-
self.assertEqual(d._id, d.insert())
268+
self.assertEqual(d._id, d.insert().inserted_id)
269269
del d.bar # unset
270270
d.save()
271271
self.assertEqual(d, Doc.find_one(d._id))

0 commit comments

Comments
 (0)