checkiz / elixir-mongo

MongoDB driver for Elixir
MIT License
101 stars 31 forks source link

UndefinedFunctionError When Selecting The Database #2

Closed rizafahmi closed 10 years ago

rizafahmi commented 10 years ago
iex(2)> mongo = Mongo.connect("localhost", 3001)
iex(3)> db = mongo.db("mydb")
** (UndefinedFunctionError) undefined function: :ok.db/2
:ok.db("mydb", {:ok, {Mongo.Server, 'localhost', 3001, :passive, 6000, #Port<0.5432>}})
ryanhall-ttec commented 10 years ago

This tripped me up when first using this module Mongo.connect returns a tuple of {:ok/:error, mongo_process /reason}

{:ok, mongo} = Mongo.connect("localhost", 3001) is what you need

this should probably be fixed in the readme

jerp commented 10 years ago

use either form:

db = Mongo.connect!("localhost", 3001)

or

{:ok, mongo} = Mongo.connect("localhost", 3001)

read.me has been updated