Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```python
- q = QueryTool()
- # Group filter
- # Using the same thing than SQL Alchemy
- q.filter_group("group1", "group2") # group1 AND group2
- q.filter_group(or_("group1", "group2")) # group1 OR group2
- q.filter_group(not_("group1")) # NOT group1
- # Is there a need to do group1 AND (group2 OR NOT group3) ?
- # Node type filter: support of basic boolean expr ?
- q.filter_class(Calculation) # using class or string ?
- q.filter_class(not_(Calculation))
- q.filter_class(Calculation, ParameterData) # OR statement, AND doesn't make
- # sense here
- # We either use kwargs to filter, or we implement custom method: filter_owner,
- # filter_time, filter_label. Might conflict if we implement querying on other
- # part of the DB later on.
- q.filter_node(type="..", owner="..") # Owner: using an user id, email, first/last name ?
- q.filter_node(label=or_("truc1", "truc2"), owner=or_("user1", "user2"))
- # Time
- q.filter_node(time=("from", "to"))
- q.filter_node(time=or_(("from", "to"), ("from", "to")))
- or q.filter_node(time(from=.., to=..))
- q.filter_node(or_(time(from=.., to=..), time(from=.., to=..)))
- # Attribute filter (same for extra, but filter_extra instead)
- q.filter_attr("attr_name", "<=", 0., label=.., on="inputs", prefetch=True) # self explanatory
- q.filter_attr("attr_name", "<=", 0., on="parents", label=.., depth=5) # Filter with a max depth
- # Prefetching
- q.prefetch("attr_name", on="relation") # Relation being input or output, that is
- # only one depth more. Still have to think what prefetching could look like with
- # more than 1 depth, if we allow more than one depth.
- # Placeholder: used in selecting stuff like atoms.*.0, and disallow dots in the *
- # placeholder.
- q.filter_attr("atoms.*.0", "=", "O")
- # Query chaining
- # Still have to define what it should be.
- q1 = QueryTool()
- # .. operations on q1
- q2 = QueryTool()
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement