Sean Russell avatar Sean Russell committed 7307e16

Adds find_one with no selector

Comments (0)

Files changed (2)

 LIBDIR=$(shell erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell)
 # get application vsn from app file
 VERSION=$(shell erl -pa ebin/ -eval 'application:load(${PKGNAME}), {ok, Vsn} = application:get_key(${PKGNAME}, vsn), io:format("~s~n", [Vsn])' -s init stop -noshell)
+	
+.PHONY: bson-make all
 
-all: src
+all: bson-make src
+	
+bson: 
+	mkdir bson
+	wget -O - --no-check-certificate \
+		https://github.com/TonyGen/bson-erlang/tarball/v0.1.2 |\
+		tar -C bson -xz --strip-components 1 -f -
+	
+bson-make: bson
+	@erlc -I bson/include -o ebin bson/src/*.erl
 
 src: FORCE
 	@erl -make
 
 test: src
+	escript t/*.erl
 	prove t/*.t
 
 clean:
 check: src
 	@dialyzer --src -r . -I include/
 
-FORCE:
+FORCE:
 -module(emongo).
 -behaviour(gen_server).
 
--export([pools/0, oid/0, add_pool/5, del_pool/1]).
+-export([pools/0, oid/0, add_pool/2, add_pool/5, del_pool/1]).
 
 -export([fold_all/6,
          find_all/2, find_all/3, find_all/4,
-         find_one/3, find_one/4]).
+         find_one/2, find_one/3, find_one/4]).
 
 -export([insert/3, update/4, update/5, delete/2, delete/3]).
 
 add_pool(PoolId, Host, Port, Database, Size) ->
     emongo_sup:start_pool(PoolId, Host, Port, Database, Size).
 
+add_pool(PoolId, Database) ->
+    emongo_sup:start_pool(PoolId, "localhost", 27017, Database, 1).
+
 del_pool(PoolId) ->
     emongo_sup:stop_pool(PoolId).
 
 %%------------------------------------------------------------------------------
 %% find_one
 %%------------------------------------------------------------------------------
+find_one(PoolId, Collection) ->
+	find_one(PoolId, Collection, [], []).
+
 find_one(PoolId, Collection, Selector) ->
     find_one(PoolId, Collection, Selector, []).
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.