Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tag: v0.8.1
Fetching contributors…

Cannot retrieve contributors at this time

186 lines (158 sloc) 5.41 kB
{% extends "api.html" %}
{% block api_content %}
<p>BossDB is a database abstraction layer used for querying and updating the database. Currently Tokyo Tyrant, Mnesia, MySQL, and PostgreSQL are supported.</p>
<h2>Functions</h2>
<p>Functions in the <code>boss_db</code> module include:</p>
{% for function in functions %}
{% if function.description_long %}
<div class="code spec">
{{ function.function }}{% if function.typespec %}{{ function.typespec }}{% endif %}
</div>
<p>{{ function.description_long }}</p>
{% endif %}
{% endfor %}
<h2>Conditions and Comparison Operators</h2>
<p>The "find" and "count" functions each take a set of <code>Conditions</code>, which specify search criteria. Similar to Microsoft's <a href="http://msdn.microsoft.com/en-us/library/bb308959.aspx">LINQ</a>, the <code>Conditions</code> can use a special non-Erlang syntax for conciseness. This special syntax can't be compiled with Erlang's default compiler, so you'll have to let Boss compile your controllers which use it.</p>
<p><code>Conditions</code> looks like a list, but each element in the list uses a notation very similar to abstract mathematical notation with a left-hand side (an atom corresponding to a record attribute), a single-character operator, and a right-hand side (values to match to the attribute). <strong>The mathematical operators are not all ASCII!</strong> You may want to copy-paste the UTF-8 operators below. As an alternative, you can also specify each condition with a 3-tuple with easier-to-type operator names.</p>
<p>As a quick example, to count the number of people younger than 25 with occupation listed as "student" or "unemployed", you would use:</p>
<div class="code">
boss_db:count(person, <br />
&nbsp;&nbsp;&nbsp;&nbsp;[age &lt; 25, occupation ∈ ["student", "unemployed"]]).
</div>
<p>This could also be written:</p>
<div class="code">
boss_db:count(person, <br />
&nbsp;&nbsp;&nbsp;&nbsp;
[{age, 'lt', 25},<br />
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
{occupation, 'in', ["student", "unemployed"]}]).
</div>
<p>Valid conditions are:</p>
<div class="code">
key = Value
</div>
<div class="code">
{key, 'equals', Value}
</div>
<p>The "key" attribute is exactly equal to Value.</p>
<div class="code">
key ≠ Value
</div>
<div class="code">
{key, 'not_equals', Value}
</div>
<p>The "key" attribute is not exactly equal to Value.</p>
<div class="code">
key ∈ [Value1, Value2, ...]
</div>
<div class="code">
{key, 'in', [Value1, Value2, ...]}
</div>
<p>The "key" attribute is equal to at least one element on the right-hand side.</p>
<div class="code">
key ∉ [Value1, Value2, ...]
</div>
<div class="code">
{key, 'not_in', [Value1, Value2, ...]}
</div>
<p>The "key" attribute is not equal to any element on the right-hand side.</p>
<div class="code">
key ∈ {Min, Max}
</div>
<div class="code">
{key, 'in', {Min, Max{{ "}}" }}
</div>
<p>The "key" attribute is numerically between Min and Max.</p>
<div class="code">
key ∉ {Min, Max}
</div>
<div class="code">
{key, 'not_in', {Min, Max{{ "}}" }}
</div>
<p>The "key" attribute is not between Min and Max.</p>
<div class="code">
key ∼ RegularExpression
</div>
<div class="code">
{key, 'matches', RegularExpression}
</div>
<p>The "key" attribute matches the RegularExpression. To perform a case-insensitive match, the expression should start with an asterisk (e.g. <code>*erlang</code>).</p>
<div class="code">
key ≁ RegularExpression
</div>
<div class="code">
{key, 'not_matches', RegularExpression}
</div>
<p>The "key" attribute does not match the RegularExpression.</p>
<div class="code">
key ∋ Token
</div>
<div class="code">
{key, 'contains', Token}
</div>
<p>The "key" attribute contains Token.</p>
<div class="code">
key ∌ Token
</div>
<div class="code">
{key, 'not_contains', Token}
</div>
<p>The "key" attribute does not contain Token.</p>
<div class="code">
key ⊇ [Token1, Token2, ...]
</div>
<div class="code">
{key, 'contains_all', [Token1, Token2, ...]}
</div>
<p>The "key" attribute contains all tokens on the right-hand side.</p>
<div class="code">
key ⊉ [Token1, Token2, ...]
</div>
<div class="code">
{key, 'not_contains_all', [Token1, Token2, ...]}
</div>
<p>The "key" attribute does not contain all tokens on the right-hand side.</p>
<div class="code">
key ∩ [Token1, Token2, ...]
</div>
<div class="code">
{key, 'contains_any', [Token1, Token2, ...]}
</div>
<p>The "key" attribute contains at least one of the tokens on the right-hand side.</p>
<div class="code">
key ⊥ [Token1, Token2, ...]
</div>
<div class="code">
{key, 'contains_none', [Token1, Token2, ...]}
</div>
<p>The "key" attribute contains none of the tokens on the right-hand side.</p>
<div class="code">
key &gt; Value
</div>
<div class="code">
{key, 'gt', Value}
</div>
<p>The "key" attribute is greater than Value.</p>
<div class="code">
key &lt; Value
</div>
<div class="code">
{key, 'lt', Value}
</div>
<p>The "key" attribute is less than Value.</p>
<div class="code">
key ≥ Value
</div>
<div class="code">
{key, 'ge', Value}
</div>
<p>The "key" attribute is greater than or equal to Value.</p>
<div class="code">
key ≤ Value
</div>
<div class="code">
{key, 'le', Value}
</div>
<p>The "key" attribute is less than or equal to Value.</p>
{% endblock %}
Jump to Line
Something went wrong with that request. Please try again.