-
Notifications
You must be signed in to change notification settings - Fork 20
DOCSP-46322: Raw queries #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOCSP-46322: Raw queries #143
Conversation
✅ Deploy Preview for docs-pymongo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Just a few minor comments but otherwise LGTM!
snooty.toml
Outdated
@@ -35,6 +35,8 @@ patch-version-number = "{+version-number+}.1" # a | |||
version = "v{+version-number+}" | |||
stable-api = "Stable API" | |||
api-root = "https://pymongo.readthedocs.io/en/{+patch-version-number+}/api/" | |||
django-odm = "MongoDB Backend for Django" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
django-odm = "MongoDB Backend for Django" | |
django-odm = "Django MongoDB Backend" |
source/interact-data/raw-queries.txt
Outdated
rather than Django methods. | ||
|
||
The Django QuerySet API provides a ``QuerySet.raw()`` method, which allows | ||
you to perform raw SQL queries on relational databases. {+django-odm+} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: To emphasize that the ODM is different
you to perform raw SQL queries on relational databases. {+django-odm+} | |
you to perform raw SQL queries on relational databases. However, {+django-odm+} |
.. code-block:: python | ||
|
||
from django.db import models | ||
from django_mongodb_backend.fields import EmbeddedModelField, ArrayField | ||
from django_mongodb_backend.managers import MongoManager | ||
|
||
class Movie(models.Model): | ||
title = models.CharField(max_length=200) | ||
plot = models.TextField(null=True) | ||
runtime = models.IntegerField(default=0) | ||
released = models.DateTimeField("release date", null=True) | ||
awards = EmbeddedModelField(Award) | ||
genres = ArrayField(models.CharField(max_length=100), blank=True) | ||
objects = MongoManager() | ||
|
||
class Meta: | ||
db_table = "movies" | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
class Theater(models.Model): | ||
theaterId = models.IntegerField(default=0) | ||
objects = MongoManager() | ||
|
||
class Meta: | ||
db_table = "theaters" | ||
|
||
def __str__(self): | ||
return self.title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should probably be moved to an includes file so we can reuse it
Applies to all code examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this to the docs-django repo now - I'll put the code in a separate file there!
Filter and Project Document Fields | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
This example runs a raw database query by calling the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example runs a raw database query by calling the | |
The following example runs a raw database query by calling the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I use "following" in the sentence right before the code example (to introduce the pipeline stages used), I removed it from the first sentence to avoid repetition
source/interact-data/raw-queries.txt
Outdated
that covers the fields you want to query. Then, specify the ``$search`` | ||
or ``$searchMeta`` stage in an aggregation pipeline parameter to | ||
the ``raw_aggregate()`` method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that covers the fields you want to query. Then, specify the ``$search`` | |
or ``$searchMeta`` stage in an aggregation pipeline parameter to | |
the ``raw_aggregate()`` method. | |
that covers the fields you want to query. Then, pass a ``$search`` | |
or ``$searchMeta`` stage in an aggregation pipeline parameter to | |
the ``raw_aggregate()`` method. |
see :atlas:`Create an Atlas Search Index </atlas-search/tutorial/create-index/>` | ||
in the Atlas documentation. | ||
|
||
This example runs an Atlas Search query by passing the ``$search`` pipeline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example runs an Atlas Search query by passing the ``$search`` pipeline | |
The following example runs an Atlas Search query by passing the ``$search`` pipeline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
source/interact-data/raw-queries.txt
Outdated
Euclidean plane. | ||
|
||
To run a geospatial query, create a ``2d`` or ``2dsphere`` index on fields | ||
containing geospatial data. Then, specify one of the following |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: I think "pass" works a little better than "specify" in this context
containing geospatial data. Then, specify one of the following | |
containing geospatial data. Then, pass one of the following |
indexes, see :manual:`Geospatial Indexes </core/indexes/index-types/index-geospatial/>` | ||
in the {+mdb-server+} manual. | ||
|
||
This example runs a geospatial query by passing the ``$match`` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example runs a geospatial query by passing the ``$match`` and | |
The following example runs a geospatial query by passing the ``$match`` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
Moved to the docs-django repo: mongodb/docs-django#1 |
Pull Request Info
PR Reviewing Guidelines
Note: This PR will move to the docs-django repo once it's created
JIRA - https://jira.mongodb.org/browse/DOCSP-46322
Staging - https://deploy-preview-143--docs-pymongo.netlify.app/interact-data/raw-queries/
Self-Review Checklist