tutorial:poly_db_querying

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:poly_db_querying [2017/07/26 14:53] paffenholztutorial:poly_db_querying [2018/02/10 11:38] (current) – deleted after merging into doku.php/tutorial/poly_db_tutorial oroehrig
Line 1: Line 1:
-==== Querying the Database ==== 
- 
-There are three commands that can be used to query the database: 
-   * ''db_query'': Obtain one or more objects that satisfy a query 
-   * ''db_count'': Count objects that satisfy a query 
-   * ''db_ids'': Obtain ''id''s of objects that satisfy a query 
- 
-== Queries == 
- 
-Queries are given as perl hashes. In its most basic form a query has the form 
-   { "PROPERTY1" => <value1>, "PROPERTY2" => <value2>, ... } 
-for example 
-   { "DIM" => 3, "N_VERTICES" => 7 } 
-Note that the database is pretty strict with types, so strings always need to be quoted, while integers should not be. The following would fail: 
-   { "DIM" => "3" } 
-The empty query is allowed: 
-   {} 
-returns all objects of a collection. You can query elements in an array with their index, e.g. 
-   { "F_VECTOR.1" => 12 } 
-gives polytopes with 12 edges (the entry at position one of the f-vector). 
- 
-You can query ranges with ''$lt'' (<), ''$lte'' (<=), ''$gt'', and ''$gte'' in the form 
-   { DIM => { '$lt' => 4 } } 
-to obtain polytopes of dimension less than 4. Observe the single quotation marks around ''$lt''. Those are necessary to prevent that perl attempts to interpret them as variables. You can bound from both sides with 
-   { DIM => { '$gte' => 4, '$lte' => 10 } } 
-to obtain those polytopes with dimensions between 4 and 10. 
- 
-''polymake'' just passes queries to MongoDB without processing them, so you can use the full query syntax of MongoDB, as explained [[https://docs.mongodb.com/manual/reference/operator/query/|here]]. 
- 
-== Obtain Objects that Satisfy a Query == 
- 
-With ''db_query'' you can send a database query to the polyDB and obtain documents matching the query. The command has a single mandatory argument, the query. All other arguments are optional. However, some must have values for the command to succeed, but they can also be given as default values via custom variables. A simple query command is 
-   { $a=db_query({'DIM' => 3}, db=>"LatticePolytopes", collection=>"SmoothReflexive"); } 
-which returns all three dimensional smooth reflexive polytopes.  
- 
-== Count Objects that Satisfy a Query == 
- 
-== Obtain Object ''ID''s that Satisfy a Query == 
- 
- 
- 
  
  • tutorial/poly_db_querying.1501080812.txt.gz
  • Last modified: 2017/07/26 14:53
  • by paffenholz