Browse Source

Add 'some tips' section to MongoEngine

pull/2964/head
Igor Ghisi 6 years ago
parent
commit
277685973f
  1. 15
      docs/patterns/mongoengine.rst

15
docs/patterns/mongoengine.rst

@ -110,7 +110,7 @@ Available operators are as follows:
* ``exists`` -- value for field exists
String queries
--------------
::::::::::::::
The following operators are available as shortcuts to querying with regular
expressions:
@ -125,6 +125,19 @@ expressions:
* ``iendswith`` -- string field ends with value (case insensitive)
* ``match`` -- performs an $elemMatch so you can match an entire document within an array
Some Tips
---------
* Attributes can be set as ``unique``
* ``MongoEngine`` creates the ``_id`` attribute automatically to acess ``ObjectIds``
* You can add choices to string fields: ``StringField(choices=['Apple', 'Banana'])``
* If you don't want your class name to be the same name as the collection, you can define
a ``meta`` class member and use the ``collection`` parameter::
class Movie(Document):
meta ={'collection': 'movie_documents'}
Accessing PyMongo MongoClient
-----------------------------

Loading…
Cancel
Save