8000 GitHub - tetsuo/tango: Textual syntax for CouchDB's Mango language
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tetsuo/tango

Repository files navigation

tango

textual syntax for the mango query language.

Syntax

tango expressions are based on the C syntax. Currently it supports basic comparison operators (==, >, >=, <, <=, ||, &&) and parentheses for explicit operator precedence.

Examples

Match documents whose "director" field has the value "Lars von Trier".

Tango:

director == "Lars von trier"

Mango:

{
  "director": "Lars von Trier"
}

&& (and) operator works as expected:

Tango:

director == "Lars von Trier" && year >= 2010

Mango:

{
  "$or": [
    {
      "director": {
        "$eq": "Lars von Trier"
      }
    }
    {
      "year": {
        "$gte": 2010
      }
    }
  ]
}

Use parentheses to create more complex queries.

Tango:

(director === "Lars von Trier" && year >= 2010) || (name == "Paul" && location == "Boston")

Mango:

{
  "$or": [
    {
      "$and": [
        {
          "=": {
            "$eq": "Lars von Trier"
          }
        },
        {
          "year": {
            "$gte": 2010
          }
        }
      ]
    },
    {
      "$and": [
        {
          "name": {
            "$eq": "Paul"
          }
        },
        {
          "location": {
            "$eq": "Boston"
          }
        }
      ]
    }
  ]
}

About

Textual syntax for CouchDB's Mango language

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •  
0