{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/comments/56621367","id":56621367,"diff_hunk":"@@ -0,0 +1,147 @@\n+'use strict';\n+\n+const mongoMethods = require('./mongoMethods');\n+\n+class Connection {\n+    constructor (url) {\n+        if (typeof url !== 'string') {\n+            throw new Error('url должен быть строкой');\n+        }\n+        let collection = null;\n+        let newProperty;\n+        let query = {};\n+        let isNot;\n+        let updateSet;\n+        let mongo = {};\n+\n+        let connection = {\n+            collection: function (name) {\n+                collection = name;\n+                return multivarka;\n+            }\n+        };\n+\n+        let multivarka = {\n+            where: function (property) {\n+                newProperty = property;\n+                return this;\n+            },\n+            not: function () {\n+                isNot = true;\n+                return this;\n+            },\n+            equal: function (value) {\n+                if (!newProperty) {\n+                    throw new Error('Не задано свойство');\n+                }\n+                if (isNot) {\n+                    query = {[newProperty]: {$ne: value}};\n+                    newProperty = null;\n+                    isNot = false;\n+                    return this;\n+                }\n+                query[newProperty] = value;\n+                newProperty = null;\n+                return this;\n+            },\n+            lessThan: function (value) {\n+                addQuery('$lt', value);\n+                return this;\n+            },\n+            greatThan: function (value) {\n+                addQuery('$gt', value);\n+                return this;\n+            },\n+            include: function (values) {\n+                addQuery('$in', values);\n+                return this;\n+            },\n+            find: cb => {\n+                connectToMongo(() => mongo.methods.find(collection, query, cb));\n+                resetQuery();\n+                return connection;\n+            },\n+            remove: cb => {\n+                connectToMongo(() => mongo.methods.remove(collection, query, cb));\n+                resetQuery();\n+                return connection;\n+            },\n+            set: function (property, value) {\n+                if (!updateSet) {\n+                    updateSet = {$set: {}};\n+                }\n+                updateSet['$set'][property] = value;\n+                return this;\n+            },\n+            update: cb => {\n+                if (!updateSet) {\n+                    cb(new Error('Не было задано обновление'));\n+                    return;\n+                }\n+                connectToMongo(() => mongo.methods.update(collection, query, updateSet, cb));\n+                resetQuery();\n+                return connection;\n+            },\n+            insert(item, cb) {\n+                if (typeof item !== 'object' && item !== null) {\n+                    cb(new Error('Вставляемый элемент должен быть объектом'));\n+                    return;\n+                }\n+                connectToMongo(() => mongo.methods.insert(collection, item, cb));\n+                resetQuery();\n+                return connection;\n+            }\n+        };\n+\n+        return connection;\n+\n+        function addQuery(operator, value) {","path":"multivarka.js","position":98,"original_position":98,"commit_id":"daadf08607a427864e38fc4145bc386ffd7d7a6b","original_commit_id":"daadf08607a427864e38fc4145bc386ffd7d7a6b","user":{"login":"gogoleff","id":4534405,"avatar_url":"https://avatars.githubusercontent.com/u/4534405?v=3","gravatar_id":"","url":"https://api.github.com/users/gogoleff","html_url":"https://github.com/gogoleff","followers_url":"https://api.github.com/users/gogoleff/followers","following_url":"https://api.github.com/users/gogoleff/following{/other_user}","gists_url":"https://api.github.com/users/gogoleff/gists{/gist_id}","starred_url":"https://api.github.com/users/gogoleff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogoleff/subscriptions","organizations_url":"https://api.github.com/users/gogoleff/orgs","repos_url":"https://api.github.com/users/gogoleff/repos","events_url":"https://api.github.com/users/gogoleff/events{/privacy}","received_events_url":"https://api.github.com/users/gogoleff/received_events","type":"User","site_admin":false},"body":"Может стать приватным методом","created_at":"2016-03-18T07:37:39Z","updated_at":"2016-03-18T07:37:39Z","html_url":"https://github.com/urfu-2015/webdev-tasks-2/pull/11#discussion_r56621367","pull_request_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/comments/56621367"},"html":{"href":"https://github.com/urfu-2015/webdev-tasks-2/pull/11#discussion_r56621367"},"pull_request":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/11","id":61129468,"html_url":"https://github.com/urfu-2015/webdev-tasks-2/pull/11","diff_url":"https://github.com/urfu-2015/webdev-tasks-2/pull/11.diff","patch_url":"https://github.com/urfu-2015/webdev-tasks-2/pull/11.patch","issue_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/issues/11","number":11,"state":"open","locked":false,"title":"Nekrasov Alexey","user":{"login":"NekrasovAlexey","id":9476133,"avatar_url":"https://avatars.githubusercontent.com/u/9476133?v=3","gravatar_id":"","url":"https://api.github.com/users/NekrasovAlexey","html_url":"https://github.com/NekrasovAlexey","followers_url":"https://api.github.com/users/NekrasovAlexey/followers","following_url":"https://api.github.com/users/NekrasovAlexey/following{/other_user}","gists_url":"https://api.github.com/users/NekrasovAlexey/gists{/gist_id}","starred_url":"https://api.github.com/users/NekrasovAlexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NekrasovAlexey/subscriptions","organizations_url":"https://api.github.com/users/NekrasovAlexey/orgs","repos_url":"https://api.github.com/users/NekrasovAlexey/repos","events_url":"https://api.github.com/users/NekrasovAlexey/events{/privacy}","received_events_url":"https://api.github.com/users/NekrasovAlexey/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-29T19:22:26Z","updated_at":"2016-03-18T07:37:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0a572446ecdd5f63093f0bee640abad5508aeed","assignee":{"login":"gogoleff","id":4534405,"avatar_url":"https://avatars.githubusercontent.com/u/4534405?v=3","gravatar_id":"","url":"https://api.github.com/users/gogoleff","html_url":"https://github.com/gogoleff","followers_url":"https://api.github.com/users/gogoleff/followers","following_url":"https://api.github.com/users/gogoleff/following{/other_user}","gists_url":"https://api.github.com/users/gogoleff/gists{/gist_id}","starred_url":"https://api.github.com/users/gogoleff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogoleff/subscriptions","organizations_url":"https://api.github.com/users/gogoleff/orgs","repos_url":"https://api.github.com/users/gogoleff/repos","events_url":"https://api.github.com/users/gogoleff/events{/privacy}","received_events_url":"https://api.github.com/users/gogoleff/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/11/commits","review_comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/11/comments","review_comment_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/issues/11/comments","statuses_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/statuses/daadf08607a427864e38fc4145bc386ffd7d7a6b","head":{"label":"NekrasovAlexey:master","ref":"master","sha":"daadf08607a427864e38fc4145bc386ffd7d7a6b","user":{"login":"NekrasovAlexey","id":9476133,"avatar_url":"https://avatars.githubusercontent.com/u/9476133?v=3","gravatar_id":"","url":"https://api.github.com/users/NekrasovAlexey","html_url":"https://github.com/NekrasovAlexey","followers_url":"https://api.github.com/users/NekrasovAlexey/followers","following_url":"https://api.github.com/users/NekrasovAlexey/following{/other_user}","gists_url":"https://api.github.com/users/NekrasovAlexey/gists{/gist_id}","starred_url":"https://api.github.com/users/NekrasovAlexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NekrasovAlexey/subscriptions","organizations_url":"https://api.github.com/users/NekrasovAlexey/orgs","repos_url":"https://api.github.com/users/NekrasovAlexey/repos","events_url":"https://api.github.com/users/NekrasovAlexey/events{/privacy}","received_events_url":"https://api.github.com/users/NekrasovAlexey/received_events","type":"User","site_admin":false},"repo":{"id":52725332,"name":"webdev-tasks-2","full_name":"NekrasovAlexey/webdev-tasks-2","owner":{"login":"NekrasovAlexey","id":9476133,"avatar_url":"https://avatars.githubusercontent.com/u/9476133?v=3","gravatar_id":"","url":"https://api.github.com/users/NekrasovAlexey","html_url":"https://github.com/NekrasovAlexey","followers_url":"https://api.github.com/users/NekrasovAlexey/followers","following_url":"https://api.github.com/users/NekrasovAlexey/following{/other_user}","gists_url":"https://api.github.com/users/NekrasovAlexey/gists{/gist_id}","starred_url":"https://api.github.com/users/NekrasovAlexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NekrasovAlexey/subscriptions","organizations_url":"https://api.github.com/users/NekrasovAlexey/orgs","repos_url":"https://api.github.com/users/NekrasovAlexey/repos","events_url":"https://api.github.com/users/NekrasovAlexey/events{/privacy}","received_events_url":"https://api.github.com/users/NekrasovAlexey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NekrasovAlexey/webdev-tasks-2","description":"","fork":true,"url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2","forks_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/forks","keys_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/teams","hooks_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/hooks","issue_events_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/issues/events{/number}","events_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/events","assignees_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/assignees{/user}","branches_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/branches{/branch}","tags_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/tags","blobs_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/git/refs{/sha}","trees_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/statuses/{sha}","languages_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/languages","stargazers_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/stargazers","contributors_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/contributors","subscribers_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/subscribers","subscription_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/subscription","commits_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/commits{/sha}","git_commits_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/git/commits{/sha}","comments_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/comments{/number}","issue_comment_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/issues/comments{/number}","contents_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/contents/{+path}","compare_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/merges","archive_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/downloads","issues_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/issues{/number}","pulls_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/pulls{/number}","milestones_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/milestones{/number}","notifications_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/labels{/name}","releases_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/releases{/id}","deployments_url":"https://api.github.com/repos/NekrasovAlexey/webdev-tasks-2/deployments","created_at":"2016-02-28T14:33:19Z","updated_at":"2016-02-29T19:21:56Z","pushed_at":"2016-03-17T09:01:40Z","git_url":"git://github.com/NekrasovAlexey/webdev-tasks-2.git","ssh_url":"git@github.com:NekrasovAlexey/webdev-tasks-2.git","clone_url":"https://github.com/NekrasovAlexey/webdev-tasks-2.git","svn_url":"https://github.com/NekrasovAlexey/webdev-tasks-2","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"urfu-2015:master","ref":"master","sha":"fbdd8fdc096c74f0d64c48286fa6d421ce1ecc9f","user":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"repo":{"id":52524444,"name":"webdev-tasks-2","full_name":"urfu-2015/webdev-tasks-2","owner":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2015/webdev-tasks-2","description":"Задача к лекции «Mongodb» – «Мультиварка»","fork":false,"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2","forks_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/forks","keys_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/teams","hooks_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/hooks","issue_events_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/events","assignees_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/tags","blobs_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/languages","stargazers_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/stargazers","contributors_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/contributors","subscribers_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/subscribers","subscription_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/subscription","commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/merges","archive_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/downloads","issues_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/deployments","created_at":"2016-02-25T12:58:40Z","updated_at":"2016-03-10T04:48:58Z","pushed_at":"2016-03-17T09:01:40Z","git_url":"git://github.com/urfu-2015/webdev-tasks-2.git","ssh_url":"git@github.com:urfu-2015/webdev-tasks-2.git","clone_url":"https://github.com/urfu-2015/webdev-tasks-2.git","svn_url":"https://github.com/urfu-2015/webdev-tasks-2","homepage":"","size":3,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":13,"forks":34,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/11"},"html":{"href":"https://github.com/urfu-2015/webdev-tasks-2/pull/11"},"issue":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/issues/11"},"comments":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-2/statuses/daadf08607a427864e38fc4145bc386ffd7d7a6b"}}}}