{"action":"created","comment":{"url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/comments/32850393","id":32850393,"diff_hunk":"@@ -101,24 +160,81 @@ impl<'a> Collection<'a> {\n         Ok(cursor.next())\n     }\n \n+    fn find_one_and_modify(&self, cmd: &mut bson::Document,\n+                           filter: bson::Document, max_time_ms: Option<i64>,\n+                           projection: Option<bson::Document>, sort: Option<bson::Document>)\n+                           -> Result<Option<bson::Document>, String> {\n+\n+        let mut new_cmd = bson::Document::new();\n+        new_cmd.insert(\"findAndModify\".to_owned(), Bson::String(self.name()));\n+        new_cmd.insert(\"query\".to_owned(), Bson::Document(filter));\n+        if sort.is_some() {\n+            new_cmd.insert(\"sort\".to_owned(), Bson::Document(sort.unwrap()));\n+        }\n+        if projection.is_some() {\n+            new_cmd.insert(\"fields\".to_owned(), Bson::Document(projection.unwrap()));\n+        }\n+\n+        for (key, val) in cmd.iter() {\n+            new_cmd.insert(key.to_owned(), val.to_owned());\n+        }\n+\n+        let res = try!(self.db.command(new_cmd));\n+        match res {\n+            Some(doc) => match doc.get(\"value\") {\n+                Some(&Bson::Document(ref nested_doc)) => Ok(Some(nested_doc.to_owned())),\n+                _ => Ok(None),\n+            },\n+            None => Ok(None),\n+        }\n+    }\n+\n+    fn find_and_update(&self, filter: bson::Document, update: bson::Document,","path":"src/client/coll/mod.rs","position":117,"original_position":117,"commit_id":"2996a24bd0904d6ee4a74d6baae397276ce88b4d","original_commit_id":"2996a24bd0904d6ee4a74d6baae397276ce88b4d","user":{"login":"vkarpov15","id":1620265,"avatar_url":"https://avatars.githubusercontent.com/u/1620265?v=3","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"body":"I'd recommend renaming this as `find_and_modify` - `find_and_update` is not very mongodb-ish nomenclature. Even if it's private, we should stick to more consistent naming conventions","created_at":"2015-06-19T17:29:09Z","updated_at":"2015-06-19T17:29:09Z","html_url":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype/pull/59#discussion_r32850393","pull_request_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/59","_links":{"self":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/comments/32850393"},"html":{"href":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype/pull/59#discussion_r32850393"},"pull_request":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/59"}}},"pull_request":{"url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/59","id":38057290,"html_url":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype/pull/59","diff_url":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype/pull/59.diff","patch_url":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype/pull/59.patch","issue_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/issues/59","number":59,"state":"open","locked":false,"title":"Query and Write Op Commands","user":{"login":"kyeah","id":2308368,"avatar_url":"https://avatars.githubusercontent.com/u/2308368?v=3","gravatar_id":"","url":"https://api.github.com/users/kyeah","html_url":"https://github.com/kyeah","followers_url":"https://api.github.com/users/kyeah/followers","following_url":"https://api.github.com/users/kyeah/following{/other_user}","gists_url":"https://api.github.com/users/kyeah/gists{/gist_id}","starred_url":"https://api.github.com/users/kyeah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyeah/subscriptions","organizations_url":"https://api.github.com/users/kyeah/orgs","repos_url":"https://api.github.com/users/kyeah/repos","events_url":"https://api.github.com/users/kyeah/events{/privacy}","received_events_url":"https://api.github.com/users/kyeah/received_events","type":"User","site_admin":false},"body":"Implements `aggregate()`, `count()`, `distinct()`, and all of the FindAndModify commands on collections with preliminary testing (extensive spec test suite being built by @saghmrossi).","created_at":"2015-06-18T21:53:05Z","updated_at":"2015-06-19T17:29:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40880354c1b71d09034b344c8ea8654aff951971","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/59/commits","review_comments_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/59/comments","review_comment_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/issues/59/comments","statuses_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/statuses/2996a24bd0904d6ee4a74d6baae397276ce88b4d","head":{"label":"kyeah:find_and_modify","ref":"find_and_modify","sha":"2996a24bd0904d6ee4a74d6baae397276ce88b4d","user":{"login":"kyeah","id":2308368,"avatar_url":"https://avatars.githubusercontent.com/u/2308368?v=3","gravatar_id":"","url":"https://api.github.com/users/kyeah","html_url":"https://github.com/kyeah","followers_url":"https://api.github.com/users/kyeah/followers","following_url":"https://api.github.com/users/kyeah/following{/other_user}","gists_url":"https://api.github.com/users/kyeah/gists{/gist_id}","starred_url":"https://api.github.com/users/kyeah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyeah/subscriptions","organizations_url":"https://api.github.com/users/kyeah/orgs","repos_url":"https://api.github.com/users/kyeah/repos","events_url":"https://api.github.com/users/kyeah/events{/privacy}","received_events_url":"https://api.github.com/users/kyeah/received_events","type":"User","site_admin":false},"repo":{"id":36325817,"name":"mongo-rust-driver-prototype","full_name":"kyeah/mongo-rust-driver-prototype","owner":{"login":"kyeah","id":2308368,"avatar_url":"https://avatars.githubusercontent.com/u/2308368?v=3","gravatar_id":"","url":"https://api.github.com/users/kyeah","html_url":"https://github.com/kyeah","followers_url":"https://api.github.com/users/kyeah/followers","following_url":"https://api.github.com/users/kyeah/following{/other_user}","gists_url":"https://api.github.com/users/kyeah/gists{/gist_id}","starred_url":"https://api.github.com/users/kyeah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyeah/subscriptions","organizations_url":"https://api.github.com/users/kyeah/orgs","repos_url":"https://api.github.com/users/kyeah/repos","events_url":"https://api.github.com/users/kyeah/events{/privacy}","received_events_url":"https://api.github.com/users/kyeah/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kyeah/mongo-rust-driver-prototype","description":"","fork":true,"url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype","forks_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/forks","keys_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/teams","hooks_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/hooks","issue_events_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/issues/events{/number}","events_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/events","assignees_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/assignees{/user}","branches_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/branches{/branch}","tags_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/tags","blobs_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/git/refs{/sha}","trees_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/statuses/{sha}","languages_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/languages","stargazers_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/stargazers","contributors_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/contributors","subscribers_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/subscribers","subscription_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/subscription","commits_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/commits{/sha}","git_commits_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/git/commits{/sha}","comments_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/comments{/number}","issue_comment_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/issues/comments{/number}","contents_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/contents/{+path}","compare_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/merges","archive_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/downloads","issues_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/issues{/number}","pulls_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/pulls{/number}","milestones_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/milestones{/number}","notifications_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/labels{/name}","releases_url":"https://api.github.com/repos/kyeah/mongo-rust-driver-prototype/releases{/id}","created_at":"2015-05-26T21:50:12Z","updated_at":"2015-05-29T21:25:41Z","pushed_at":"2015-06-18T21:48:29Z","git_url":"git://github.com/kyeah/mongo-rust-driver-prototype.git","ssh_url":"git@github.com:kyeah/mongo-rust-driver-prototype.git","clone_url":"https://github.com/kyeah/mongo-rust-driver-prototype.git","svn_url":"https://github.com/kyeah/mongo-rust-driver-prototype","homepage":"10gen-interns.github.io/mongo-rust-driver-prototype","size":1434,"stargazers_count":2,"watchers_count":2,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"1.0"}},"base":{"label":"mongodbinc-interns:1.0","ref":"1.0","sha":"2fa494ebb2cd39d1e1fef0db14bdbecb3b5db68f","user":{"login":"mongodbinc-interns","id":4552450,"avatar_url":"https://avatars.githubusercontent.com/u/4552450?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodbinc-interns","html_url":"https://github.com/mongodbinc-interns","followers_url":"https://api.github.com/users/mongodbinc-interns/followers","following_url":"https://api.github.com/users/mongodbinc-interns/following{/other_user}","gists_url":"https://api.github.com/users/mongodbinc-interns/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodbinc-interns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodbinc-interns/subscriptions","organizations_url":"https://api.github.com/users/mongodbinc-interns/orgs","repos_url":"https://api.github.com/users/mongodbinc-interns/repos","events_url":"https://api.github.com/users/mongodbinc-interns/events{/privacy}","received_events_url":"https://api.github.com/users/mongodbinc-interns/received_events","type":"Organization","site_admin":false},"repo":{"id":10370054,"name":"mongo-rust-driver-prototype","full_name":"mongodbinc-interns/mongo-rust-driver-prototype","owner":{"login":"mongodbinc-interns","id":4552450,"avatar_url":"https://avatars.githubusercontent.com/u/4552450?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodbinc-interns","html_url":"https://github.com/mongodbinc-interns","followers_url":"https://api.github.com/users/mongodbinc-interns/followers","following_url":"https://api.github.com/users/mongodbinc-interns/following{/other_user}","gists_url":"https://api.github.com/users/mongodbinc-interns/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodbinc-interns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodbinc-interns/subscriptions","organizations_url":"https://api.github.com/users/mongodbinc-interns/orgs","repos_url":"https://api.github.com/users/mongodbinc-interns/repos","events_url":"https://api.github.com/users/mongodbinc-interns/events{/privacy}","received_events_url":"https://api.github.com/users/mongodbinc-interns/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype","description":"","fork":false,"url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype","forks_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/forks","keys_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/teams","hooks_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/hooks","issue_events_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/issues/events{/number}","events_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/events","assignees_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/assignees{/user}","branches_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/branches{/branch}","tags_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/tags","blobs_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/languages","stargazers_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/stargazers","contributors_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/contributors","subscribers_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/subscribers","subscription_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/subscription","commits_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/contents/{+path}","compare_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/merges","archive_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/downloads","issues_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/issues{/number}","pulls_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/labels{/name}","releases_url":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/releases{/id}","created_at":"2013-05-29T21:42:45Z","updated_at":"2015-06-19T04:58:10Z","pushed_at":"2015-06-18T21:53:05Z","git_url":"git://github.com/mongodbinc-interns/mongo-rust-driver-prototype.git","ssh_url":"git@github.com:mongodbinc-interns/mongo-rust-driver-prototype.git","clone_url":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype.git","svn_url":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype","homepage":"10gen-interns.github.io/mongo-rust-driver-prototype","size":2256,"stargazers_count":38,"watchers_count":38,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":18,"mirror_url":null,"open_issues_count":2,"forks":18,"open_issues":2,"watchers":38,"default_branch":"1.0"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/59"},"html":{"href":"https://github.com/mongodbinc-interns/mongo-rust-driver-prototype/pull/59"},"issue":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/issues/59"},"comments":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/issues/59/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/59/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/pulls/59/commits"},"statuses":{"href":"https://api.github.com/repos/mongodbinc-interns/mongo-rust-driver-prototype/statuses/2996a24bd0904d6ee4a74d6baae397276ce88b4d"}}}}