Last active
August 29, 2015 14:15
-
-
Save numberoverzero/3e397b26134c0a0121f8 to your computer and use it in GitHub Desktop.
Sample syntax for various query operations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Single hash key, multiple filters | |
| # ================================= | |
| # Pure condition syntax, no **kwargs overloading | |
| # ---------------------------------------------- | |
| q = engine.query(Forum) | |
| .key(Forum.name == "S3") | |
| .filter(Forum.subscribers > MIN_SUBSCRIBERS, | |
| Forum.views >= MIN_VIEWS) | |
| # Only overload **kwargs, no condition syntax | |
| #-------------------------------------------- | |
| q = engine.query(Forum) | |
| .key(name="S3") | |
| .filter(subscribers=GT(MIN_SUBSCRIBERS), | |
| views=GE(MIN_VIEWS)) | |
| # Hash and Range keys, single filter | |
| # ================================= | |
| # Pure condition syntax, no **kwargs overloading | |
| # ---------------------------------------------- | |
| q = engine.query(Thread) | |
| .key(Thread.forum_name == "S3", | |
| Thread.subject.between("Hello", "World")) | |
| .filter(Thread.replies >= MIN_REPLIES) | |
| # Only overload **kwargs, no condition syntax | |
| #-------------------------------------------- | |
| q = engine.query(Thread) | |
| .key(forum_name="S3", | |
| subject=between("Hello", "World")) | |
| .filter(replies=GE(MIN_REPLIES)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment