Anonymous avatar Anonymous committed 8f0c380

adding some insert, update and delete documentation

Comments (0)

Files changed (1)

 
 	emongo:add_pool(PoolName, Host, Port, Database, PoolSize) -> ok
 
+## Insert
+
+__PoolName__ = atom()  
+__CollectionName__ = string()  
+__Document__ = [{Key, Val}]  
+__Documents__ = [Document]  
+
+	emongo:insert(PoolName, CollectionName, Document) -> ok
+	emongo:insert(PoolName, CollectionName, Documents) -> ok
+	
+### Examples
+
+	%% insert a single document with two fields into the "collection" collection
+	emongo:insert(test, "collection", [{"field1", "value1"}, {"field2", "value2"}]).
+	
+	%% insert two documents, each with a single field into the "collection" collection
+	emongo:insert(test, "collection", [[{"document1_field1", "value1"}], [{"document2_field1", "value1"}]]).	
+
+## Update
+
+__PoolName__ = atom()  
+__CollectionName__ = string()  
+__Selector__ = Document  
+__Document__ = [{Key, Val}]  
+__Upsert__ = true | false (insert a new document if the selector does not match an existing document)
+
+	%% by default upsert == false
+	emongo:update(PoolName, CollectionName, Selector, Document) -> ok
+	emongo:update(PoolName, CollectionName, Selector, Document, Upsert) -> ok
+	
+### Examples
+
+	%% update the document that matches "field1" == "value1"
+	emongo:update(test, "collection", [{"field1", "value1"}], [{"field1", "value1"}, {"field2", "value2"}]).
+
+## Delete
+
+__PoolName__ = atom()  
+__CollectionName__ = string()  
+__Selector__ = Document  
+
+	%% delete all documents in a collection
+	emongo:delete(PoolName, CollectionName) -> ok
+	
+	%% delete all documents in a collection that match a selector
+	emongo:delete(PoolName, CollectionName, Selector) -> ok
+	
 ## Find
 	
 __Options__ = {timeout, Timeout} | {limit, Limit} | {offset, Offset} | {orderby, Orderby} | {fields, Fields} | response_options  
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.