|
|
@ -110,7 +110,7 @@ Available operators are as follows: |
|
|
|
* ``exists`` -- value for field exists |
|
|
|
* ``exists`` -- value for field exists |
|
|
|
|
|
|
|
|
|
|
|
String queries |
|
|
|
String queries |
|
|
|
-------------- |
|
|
|
:::::::::::::: |
|
|
|
|
|
|
|
|
|
|
|
The following operators are available as shortcuts to querying with regular |
|
|
|
The following operators are available as shortcuts to querying with regular |
|
|
|
expressions: |
|
|
|
expressions: |
|
|
@ -125,6 +125,19 @@ expressions: |
|
|
|
* ``iendswith`` -- string field ends with value (case insensitive) |
|
|
|
* ``iendswith`` -- string field ends with value (case insensitive) |
|
|
|
* ``match`` -- performs an $elemMatch so you can match an entire document within an array |
|
|
|
* ``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 |
|
|
|
Accessing PyMongo MongoClient |
|
|
|
----------------------------- |
|
|
|
----------------------------- |
|
|
|
|
|
|
|
|
|
|
|