Skip to main content

A useful tool to parse the query string parameters on a resource into a MongoDB query object (compatible with PyMongo and MongoEngine).

Project description

PyQS Mongo

A useful tool to parse the query string parameters on a resource into a MongoDB query object (compatible with PyMongo and MongoEngine).

Inspired by: https://github.com/Turistforeningen/node-mongo-querystring

Features (Coming Soon)

  • Aliased query parameters
  • Blacklisted query parameters
  • Whitelisted query parameters
  • Geospatial operators
  • Date comparision
  • Basic operators to support
    • $exists
    • $regex

Features

  • Basic operators
    • $eq
    • $gt
    • $gte
    • $lt
    • $lte
    • $ne
    • $in
    • $nin
operation query string query object
equal ?foo=bar { foo: "bar" }
unequal ?foo=!bar { foo: { $ne: "bar" }}
greater than ?foo=>10 { foo: { $gt: 10 }}
less than ?foo=<10 { foo: { $lt: 10 }}
greater than or equal to ?foo=>=10 { foo: { $gte: 10 }}
less than or equal to ?foo=<=10 { foo: { $lte: 10 }}
in array ?foo=[]bar&foo=[]baz { foo: { $in: ['bar', 'baz'] }}
not in array ?foo=[!]bar&foo=[!]baz { foo: { $nin: ['bar', 'baz'] }}

Install

pip install pyqs-mongo

API

from pyqs_mongo import parse

qs = 'name=ahmed&company=someCompany&age=>=20&age=<=50&username=[]ahmed&username=[]adh&username=[!]some'
query = parse(qs)
print(query)

Tests

  • Coming Soon

Collaborators

  • Ahmed Pyar Ali - @mrpycharm

MIT Licensed

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqs-mongo-0.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyqs_mongo-0.0.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pyqs-mongo-0.0.1.tar.gz.

File metadata

  • Download URL: pyqs-mongo-0.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

File hashes

Hashes for pyqs-mongo-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1c7cd5e66bd149bc8df7bda84ce11d4366fd2781a7a0c928ba9f20afda540d84
MD5 5931656a7a6d443f3c6aa779f6b7a9f2
BLAKE2b-256 bf9816fe1aba84b5b1bfb0ddba7b7cc78bc9f0b665c2e04fc19134cef292a2da

See more details on using hashes here.

File details

Details for the file pyqs_mongo-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyqs_mongo-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

File hashes

Hashes for pyqs_mongo-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c98f10c56536b40784c0f905701e9c96a550d8f3b75eaf0e19a03c4d11981ee
MD5 b9e9071257abcb231483ed77ddff354f
BLAKE2b-256 fd3eb2b0b08c444ab7fcbad007f1398ca1a00acf8d75c74bdacc61cee44f90af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page