Skip to content

Commit 7d955df

Browse files
authored
Fix markdown syntax in README.md
1 parent 3965bf7 commit 7d955df

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

README.md

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,67 @@ If you were expecting `Exrethinkdb` you are in the right place. We decided to ch
77

88
I just set up a channel on the Elixir slack, so if you are on there join #rethinkdb.
99

10-
###Recent changes
10+
### Recent changes
11+
12+
#### 0.4.0
1113

12-
####0.4.0
1314
* Extract Changefeed out into separate [package](https://github.com/hamiltop/rethinkdb_changefeed)
1415
* Accept keyword options with queries
1516

16-
##Getting Started
17+
## Getting Started
1718

1819
See [API documentation](http://hexdocs.pm/rethinkdb/) for more details.
1920

20-
###Connection
21+
### Connection
2122

2223
Connections are managed by a process. Start the process by calling `start_link/1`. See [documentation for `Connection.start_link/1`](http://hexdocs.pm/rethinkdb/RethinkDB.Connection.html#start_link/1) for supported options.
2324

24-
####Basic Remote Connection
25+
#### Basic Remote Connection
26+
2527
```elixir
2628
{:ok, conn} = RethinkDB.Connection.start_link([host: "10.0.0.17", port: 28015])
2729
```
2830

29-
####Named Connection
31+
#### Named Connection
32+
3033
```elixir
3134
{:ok, conn} = RethinkDB.Connection.start_link([name: :foo])
3235
```
3336

34-
####Supervised Connection
37+
#### Supervised Connection
38+
3539
Start the supervisor with:
40+
3641
```elixir
3742
worker(RethinkDB.Connection, [[name: :foo]])
3843
worker(RethinkDB.Connection, [[name: :bar, host: 'localhost', port: 28015]])
3944
```
4045

41-
####Default Connection
46+
#### Default Connection
47+
4248
An `RethinkDB.Connection` does parallel queries via pipelining. It can and should be shared among multiple processes. Because of this, it is common to have one connection shared in your application. To create a default connection, we create a new module and `use RethinkDB.Connection`.
49+
4350
```elixir
4451
defmodule FooDatabase do
4552
use RethinkDB.Connection
4653
end
4754
```
55+
4856
This connection can be supervised without a name (it will assume the module as the name).
57+
4958
```elixir
5059
worker(FooDatabase, [])
5160
```
61+
5262
Queries can be run without providing a connection (it will use the name connection).
63+
5364
```elixir
5465
import RethinkDB.Query
5566
table("people") |> FooDatabase.run
5667
```
5768

58-
####Connection Pooling
69+
#### Connection Pooling
70+
5971
To use a connection pool, add Poolboy to your dependencies:
6072

6173
```elixir
@@ -78,43 +90,50 @@ table("people") |> db
7890
:poolboy.checkin(:rethinkdb_pool, db)
7991
```
8092

81-
###Query
93+
### Query
94+
8295
`RethinkDB.run/2` accepts a process as the second argument (to facilitate piping).
8396

84-
####Insert
97+
#### Insert
98+
8599
```elixir
86100

87101
q = Query.table("people")
88102
|> Query.insert(%{first_name: "John", last_name: "Smith"})
89103
|> RethinkDB.run conn
90104
```
91105

92-
####Filter
106+
#### Filter
107+
93108
```elixir
94109
q = Query.table("people")
95110
|> Query.filter(%{last_name: "Smith"})
96111
|> RethinkDB.run conn
97112
```
98113

99-
####Functions
114+
#### Functions
115+
100116
RethinkDB supports RethinkDB functions in queries. There are two approaches you can take:
101117

102118
Use RethinkDB operators
119+
103120
```elixir
104121
import RethinkDB.Query
105122

106123
make_array([1,2,3]) |> map(fn (x) -> add(x, 1) end)
107124
```
108125

109126
Use Elixir operators via the lambda macro
127+
110128
```elixir
111129
require RethinkDB.Lambda
112130
import RethinkDB.Lambda
113131

114132
make_array([1,2,3]) |> map(lambda fn (x) -> x + 1 end)
115133
```
116134

117-
####Map
135+
#### Map
136+
118137
```elixir
119138
require RethinkDB.Lambda
120139
import Query
@@ -132,6 +151,7 @@ table("people")
132151
See [query.ex](lib/rethinkdb/query.ex) for more basic queries. If you don't see something supported, please open an issue. We're moving fast and any guidance on desired features is helpful.
133152

134153
#### Indexes
154+
135155
```elixir
136156
# Simple indexes
137157
# create
@@ -156,9 +176,10 @@ result = Query.table("people")
156176
|> Query.get_all([["Will", "Smith"], ["James", "Bond"]], index: "full_name")
157177
|> RethinkDB.run conn
158178
```
179+
159180
One limitation we have in Elixir is that we don't support varargs. So in JavaScript you would do `getAll(key1, key2, {index: "uniqueness"})`. In Elixir we have to do `get_all([key1, key2], index: "uniqueness")`. With a single key it becomes `get_all([key1], index: "uniqueness")` and when `key1` is `[partA, partB]` you have to do `get_all([[partA, partB]], index: "uniqueness")`
160181

161-
###Changes
182+
### Changes
162183

163184
Change feeds can be consumed either incrementally (by calling `RethinkDB.next/1`) or via the Enumerable Protocol.
164185

@@ -172,11 +193,13 @@ first_change = RethinkDB.next results
172193
# get stream, chunked in groups of 5, Inspect
173194
results |> Stream.chunk(5) |> Enum.each &IO.inspect/1
174195
```
175-
###Supervised Changefeeds
196+
197+
### Supervised Changefeeds
176198

177199
Supervised Changefeeds (an OTP behavior for running a changefeed as a process) have been moved to their own repo to enable independent release cycles. See https://github.com/hamiltop/rethinkdb_changefeed
178200

179-
###Roadmap
201+
### Roadmap
202+
180203
Version 1.0.0 will be limited to individual connections and implement the entire documented ReQL (as of rethinkdb 2.0)
181204

182205
While not provided by this library, we will also include example code for:
@@ -186,12 +209,14 @@ While not provided by this library, we will also include example code for:
186209
The goal for 1.0.0 is to be stable. Issues have been filed for work that needs to be completed before 1.0.0 and tagged with the 1.0.0 milestone.
187210

188211

189-
###Example Apps
212+
### Example Apps
213+
190214
Checkout the wiki page for various [example apps](https://github.com/hamiltop/rethinkdb-elixir/wiki/Example-Apps)
191215

216+
### Contributing
192217

193-
###Contributing
194218
Contributions are welcome. Take a look at the Issues. Anything that is tagged `Help Wanted` or `Feedback Wanted` is a good candidate for contributions. Even if you don't know where to start, respond to an interesting issue and you will be pointed in the right direction.
195219

196-
####Testing
220+
#### Testing
221+
197222
Be intentional. Whether you are writing production code or tests, make sure there is value in the test being written.

0 commit comments

Comments
 (0)