Skip to content
Newer
Older
100644 188 lines (173 sloc) 7.25 KB
b342da2 Added a documentation website generator.
Evan Miller authored
1 {% extends "api.html" %}
2 {% block api_content %}
376de97 @evanmiller MySQL support (first cut)
evanmiller authored
3 <p>BossDB is a database abstraction layer used for querying and updating the database. Currently Tokyo Tyrant, Mnesia, MySQL, and PostgreSQL are supported.</p>
443ab75 @evanmiller New query language; add support for boss_db:find/2
evanmiller authored
4
d791d38 Doc fixes
Evan Miller authored
5
6 <h2>Functions</h2>
7
8 <p>Functions in the <code>boss_db</code> module include:</p>
dd57463 @timClicks API Doc Improvements
timClicks authored
9
f2a158e @timClicks HTML improvements; minor CSS
timClicks authored
10 {% for function in functions %}
11 {% if function.description_long %}
12 <div class="example {% cycle 'row1' 'row2' %}">
13 <div class="code">
dd57463 @timClicks API Doc Improvements
timClicks authored
14 {{ function.function }}{% if function.typespec %}{{ function.typespec }}{% endif %}
f2a158e @timClicks HTML improvements; minor CSS
timClicks authored
15 </div>
16 <p>{{ function.description_long }}</p>
17 </div>
18 {% endif %}
19 {% endfor %}
dd57463 @timClicks API Doc Improvements
timClicks authored
20
7cec862 @zkessin document new_from_json/2
zkessin authored
21 <h2>Creating a Model from a JSON record</h2>
22 <p>
23 If your project is anything like mine then you will probably have a
24 case where you get a JSON in from the user or an api and you want to
25 convert it to a model. we have a new
26 function <b>boss_record:new_from_json/2</b> which lets you do that
27 automaticly. To run this call new_from_json/2 with your model (atom)
28 and your json record. Note that if you have a field called 'id' you
29 will have to rename or remove it
30 </p>
d791d38 Doc fixes
Evan Miller authored
31
24c2e5e @evanmiller Support for searches and regexes in BossDB
evanmiller authored
32 <h2>Conditions and Comparison Operators</h2>
443ab75 @evanmiller New query language; add support for boss_db:find/2
evanmiller authored
33
34 <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>
35
27e7274 @evanmiller Pedestrian (ASCII-only) query syntax
evanmiller authored
36 <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>
443ab75 @evanmiller New query language; add support for boss_db:find/2
evanmiller authored
37
38 <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>
f2a158e @timClicks HTML improvements; minor CSS
timClicks authored
39 <pre class="code">
40 boss_db:count(person,
41 [age &lt; 25, occupation ∈ ["student", "unemployed"]]).
42 </pre>
27e7274 @evanmiller Pedestrian (ASCII-only) query syntax
evanmiller authored
43 <p>This could also be written:</p>
f2a158e @timClicks HTML improvements; minor CSS
timClicks authored
44 <pre class="code">
45 boss_db:count(person,
46 [{age, 'lt', 25},
82b6af0 @evanmiller Prep for 0.3.10
evanmiller authored
47 {occupation, 'in', ["student", "unemployed"]}]).
f2a158e @timClicks HTML improvements; minor CSS
timClicks authored
48 </pre>
443ab75 @evanmiller New query language; add support for boss_db:find/2
evanmiller authored
49
dd57463 @timClicks API Doc Improvements
timClicks authored
50 <h2>Valid <code>Conditions</code></h2>
51
f2a158e @timClicks HTML improvements; minor CSS
timClicks authored
52 <div class="example row1">
53 <div class=" code">
54 <code>key = Value</code><br>
55 <code>{key, 'equals', Value}</code>
56 </div>
57 <p>
58 The "<code>key</code>" attribute is exactly equal to <code>Value</code>.
59 </p>
60 </div>
61
62 <div class="example row2">
63 <div class=" code">
64 <code>key ≠ Value</code><br>
65 <code>{key, 'not_equals', Value}</code>
66 </div>
67 <p>
77fe6e5 @davidw Doc fix explaining how to get a foo IS NOT NULL query.
davidw authored
68 The "<code>key</code>" attribute is not exactly equal to <code>Value</code>. This is also used to attain a query like <code>foo IS NOT NULL</code>: <code>{foo, 'not_equals', undefined}</code>.
f2a158e @timClicks HTML improvements; minor CSS
timClicks authored
69 </p>
70 </div>
71 <div class="example row1">
72 <div class="code">
73 <code>key ∈ [Value1, Value2, ...]</code><br>
74 <code>{key, 'in', [Value1, Value2, ...]}</code>
75 </div>
76 <p>The "<code>key</code>" attribute is equal to at least one element on the right-hand side.
77 </p>
78 </div>
79 <div class="example row2">
80 <div class="code">
81 <code>key ∉ [Value1, Value2, ...]</code><br>
82 <code>{key, 'not_in', [Value1, Value2, ...]}</code>
83 </div>
84 <p>The "<code>key</code>" attribute is not equal to any element on the right-hand side.</p>
85 </div>
86 <div class="example row1">
87 <div class="code">
88 <code>key ∈ {Min, Max}</code><br>
89 <code>{key, 'in', {Min, Max}}</code>
90 </div>
91 <p>The "<code>key</code>" attribute is numerically between <code>Min</code> and <code>Max</code>.
92 </p>
93 </div>
94 <div class="example row2">
95 <div class="code">
96 <code>key ∉ {Min, Max}</code><br>
97 <code>{key, 'not_in', {Min, Max}}</code>
98 </div>
99 <p>The "<code>key</code>" attribute is not between <code>Min</code> and <code>Max</code>.</p>
100 </div>
101 <div class="example row1">
102 <div class="code">
103 <code>key ∼ RegularExpression</code><br>
104 <code>{key, 'matches', RegularExpression}</code>
105 </div>
106 <p>The "<code>key</code>" attribute matches the <code>RegularExpression</code>. To perform a case-insensitive match, the expression should start with an asterisk (e.g. <code>*erlang</code>).</p>
107 </div>
108 <div class="example row2">
109 <div class="code">
110 <code>key ≁ RegularExpression</code><br>
111 <code>{key, 'not_matches', RegularExpression}</code>
112 </div>
113 <p>The "key" attribute does not match the <code>RegularExpression.</code>.</p>
114 </div>
115 <div class="example row1">
116 <div class="code">
117 <code>key ∋ Token</code><br>
118 <code>{key, 'contains', Token}</code>
119 </div>
120 <p>The "key" attribute contains <code>Token</code>.</p>
121 </div>
122 <div class="example row2">
123 <div class="code">
124 <code>key ∌ Token</code><br>
125 <code>{key, 'not_contains', Token}</code>
126 </div>
127 <p>The "<code>key</code>" attribute does not contain <code>Token</code>.</p>
128 </div>
129 <div class="example row1">
130 <div class="code">
131 <code>key ⊇ [Token1, Token2, ...]</code><br>
132 <code>{key, 'contains_all', [Token1, Token2, ...]}</code>
133 </div>
134 <p>The "<code>key</code>" attribute contains all tokens on the right-hand side.</p>
135 </div>
136 <div class="example row2">
137 <div class="code">
138 <code>key ⊉ [Token1, Token2, ...]</code><br>
139 <code>{key, 'not_contains_all', [Token1, Token2, ...]}</code>
140 </div>
141 <p>The "<code>key</code>" attribute does not contain all tokens on the right-hand side.</p>
142 </div>
143 <div class="example row1">
144 <div class="code">
145 <code>key ∩ [Token1, Token2, ...]</code><br>
f92d5e7 @drobakowski Clean inconsistent whitespaces while respecting .editorconfig
drobakowski authored
146 <code>{key, 'contains_any', [Token1, Token2, ...]}</code>
f2a158e @timClicks HTML improvements; minor CSS
timClicks authored
147 </div>
148 <p>The "<code>key</code>" attribute contains at least one of the tokens on the right-hand side.</p>
149 </div>
150 <div class="example row2">
151 <div class="code">
152 <code>key ⊥ [Token1, Token2, ...]</code><br>
153 <code>{key, 'contains_none', [Token1, Token2, ...]}</code>
154 </div>
155 <p>The "<code>key</code>" attribute contains none of the tokens on the right-hand side.</p>
156 </div>
157 <div class="example row1">
158 <div class="code">
159 <code>key &gt; Value</code><br>
160 <code>{key, 'gt', Value}</code>
161 </div>
162 <p>The "<code>key</code>" attribute is greater than <code>Value</code>.</p>
163 </div>
164 <div class="example row2">
165 <div class="code">
166 <code>key &lt; Value</code><br>
167 <code>{key, 'lt', Value}</code>
168 </div>
169 <p>The "key" attribute is less than <code>Value</code>.</p>
170 </div>
171 <div class="example row1">
172 <div class="code">
173 <code>key ≥ Value</code><br>
174 <code>{key, 'ge', Value}</code>
175 </div>
176 <p>The "key" attribute is greater than or equal to <code>Value</code>.</p>
177 </div>
178 <div class="example row2">
179 <div class="code">
180 <code>key ≤ Value</code><br>
181 <code>{key, 'le', Value}</code>
182 </div>
183 <p>The "key" attribute is less than or equal to <code>Value</code>.</p>
184 </div>
185
443ab75 @evanmiller New query language; add support for boss_db:find/2
evanmiller authored
186
b342da2 Added a documentation website generator.
Evan Miller authored
187 {% endblock %}
Something went wrong with that request. Please try again.