mongoq

Generates MongoDB queries from simple Python expressions
Download

mongoq Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Alon Horev
  • Publisher web site:
  • http://github.com/alonho/

mongoq Tags


mongoq Description

mongoq is a module that generates MongoDB queries from simple Python expressions.Installationpip install mongoqAlgebra>>> from mongoq import Q>>> Q.attr == 3{'attr': 3}>>> Q.attr != 3{'attr': {'$ne': 3}}>>> (Q.attr1 == 3) + (Q.attr2 >= 4){'attr2': {'$gte': 4}, 'attr1': 3}>>> (Q.attr < 3) | (Q.attr > 5){'$or': }>>> ~(Q.attr1 >> (Q.attr1 == 3) | ((Q.attr2 == 4) & (Q.attr3 == 5)){'$or': }]}>>> (Q.attr == 3).nor(Q.attr == 4){'$nor': }Nested Documents>>> Q.subdoc.attr > 5{'subdoc.attr': {'$gt': 5}}Builtins>>> Q.attr.notcontained(){'attr': {'$nin': }}>>> Q.attr.contained(){'attr': {'$in': }}>>> Q.attr.exists(False){'attr': {'$exists': False}} >>> Q.attr.type(3){'attr': {'$type': 3}}>>> Q.attr.where('this.a == this.b'){'attr': {'$where': 'this.a == this.b'}}>>> Q.attr.mod(10, 3){'attr': {'$mod': }}>>> Q.attr.regex('bla').options('i'){'attr': {'$options': 'i', '$regex': 'bla'}}Array Queries>>> Q.array.all(){'array': {'$all': }}>>> Q.array.size(3){'array': {'$size': 3}}>>> Q.array.elemMatch(Q.attr > 1){'array': {'$elemMatch': {'attr': {'$gt': 1}}}}Custom Queries>>> Q.attr.value({'$bla': 3}){'attr': {'$bla': 3}}>>> (Q.attr > 0).value({'$bla': 3}){'attr': {'$gt': 0, '$bla': 3}}Product's homepage


mongoq Related Software