local MongoClient = require("mongorover.MongoClient")
local client = MongoClient.new("mongodb://localhost:27017/")
local exampleDatabase = client:getDatabase("exampleDB")
local exampleCollection = exampleDatabase:getCollection("exampleCollection")

-- Drop database to get a clean slate for this example.

-- There are zero documents in the dropped collection.
print("number of documents in collection", exampleCollection:count({}))

-- After the insert, there should be three documents.
local arrayOfDocuments = {{color = "blue"}, {color = "blue"}, {color = "red"}}
print("number of documents in collection", exampleCollection:count({}))

-- Update one document that has the color of blue and make it red.
local result = exampleCollection:update_one({color = "blue"}, {["$set"] = {color = "red"}})

-- Now there is one blue document and two red documents.
print("number of blue documents in collection", exampleCollection:count({color = "blue"}))
print("number of red documents in collection",  exampleCollection:count({color = "red"}))

-- result is an UpdateResult.

-- It has information about the update operation.
for k,v in pairs(result) do

---- This is the output of this script.

-- number of documents in collection	0
-- number of documents in collection	3
-- number of blue documents in collection	1
-- number of red documents in collection	2
-- <UpdateResult object at table: 0x7ff003703750>
-- modified_count	1
-- matched_count	1
-- raw_result	table: 0x7ff0037035d0
generated by LDoc 1.4.3 Last updated 2015-09-16 03:55:02