Skip to content

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

Conversation

norareidy
Copy link
Collaborator

@norareidy norareidy commented Jan 9, 2025

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

  • Is this free of any warnings or errors in the RST?
  • Did you run a spell-check?
  • Did you run a grammar-check?
  • Are all the links working?
  • Are the facets and meta keywords accurate?

Copy link

netlify bot commented Jan 9, 2025

Deploy Preview for docs-pymongo ready!

Name Link
🔨 Latest commit 264dac1
🔍 Latest deploy log https://app.netlify.com/sites/docs-pymongo/deploys/6786b09037cb4100083f9764
😎 Deploy Preview https://deploy-preview-143--docs-pymongo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@aclark4life aclark4life left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@jordan-smith721 jordan-smith721 left a 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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
django-odm = "MongoDB Backend for Django"
django-odm = "Django MongoDB Backend"

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+}
Copy link
Collaborator

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

Suggested change
you to perform raw SQL queries on relational databases. {+django-odm+}
you to perform raw SQL queries on relational databases. However, {+django-odm+}

Comment on lines +41 to +70
.. 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
Copy link
Collaborator

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

Copy link
Collaborator Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This example runs a raw database query by calling the
The following example runs a raw database query by calling the

Copy link
Collaborator Author

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

Comment on lines 168 to 170
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Euclidean plane.

To run a geospatial query, create a ``2d`` or ``2dsphere`` index on fields
containing geospatial data. Then, specify one of the following
Copy link
Collaborator

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

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This example runs a geospatial query by passing the ``$match`` and
The following example runs a geospatial query by passing the ``$match`` and

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

@norareidy
Copy link
Collaborator Author

Moved to the docs-django repo: mongodb/docs-django#1

@norareidy norareidy closed this Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants