{"action":"created","comment":{"url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/comments/36872869","id":36872869,"diff_hunk":"@@ -53,13 +58,53 @@ def upsert(self, doc, namespace, timestamp):\n         \"ns\": namespace,\n         \"_ts\": timestamp\n     }\n+    doc = self._formatter.format_document(doc)\n+    self.store_nodes_and_relationships(doc, doc_type, doc_id)\n+    \n   \n+  def store_nodes_and_relationships(self, doc, doc_type, doc_id):\n+    self.build_nodes(doc_type, doc, doc_id)\n+    for node_type in self.doc_types:\n+      self.apply_id_constraint(node_type)\n+    tx = self.graph.cypher.begin()\n+    for query in self.query_nodes.keys():\n+      tx.append(query, {\"parameters\":self.query_nodes[query]})\n+    main_type = self.doc_types.pop(0)\n+    for node_type in self.doc_types:\n+      tx.append(self.build_relationships(doc_id, main_type, node_type))\n+    tx.commit()\n+\n+  def build_nodes(self, doc_type, hash, id):\n+    self.doc_types.append(doc_type)\n+    parameters = {'id':id}\n+    for key in hash.keys():\n+      if (type(hash[key]) is str) or (type(hash[key]) is list):","path":"mongo_connector/doc_managers/neo4j_doc_manager.py","position":60,"original_position":60,"commit_id":"dce1283592307662b2fe063ffaefe1cc84762a7d","original_commit_id":"dce1283592307662b2fe063ffaefe1cc84762a7d","user":{"login":"jexp","id":67427,"avatar_url":"https://avatars.githubusercontent.com/u/67427?v=3","gravatar_id":"","url":"https://api.github.com/users/jexp","html_url":"https://github.com/jexp","followers_url":"https://api.github.com/users/jexp/followers","following_url":"https://api.github.com/users/jexp/following{/other_user}","gists_url":"https://api.github.com/users/jexp/gists{/gist_id}","starred_url":"https://api.github.com/users/jexp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jexp/subscriptions","organizations_url":"https://api.github.com/users/jexp/orgs","repos_url":"https://api.github.com/users/jexp/repos","events_url":"https://api.github.com/users/jexp/events{/privacy}","received_events_url":"https://api.github.com/users/jexp/received_events","type":"User","site_admin":false},"body":"the question was also more about the if condition, where strings and lists are used as parameters, and all other datatypes will cause the call to `build_nodes`","created_at":"2015-08-12T15:22:50Z","updated_at":"2015-08-12T15:22:50Z","html_url":"https://github.com/neo4j-contrib/neo4j_doc_manager/pull/2#discussion_r36872869","pull_request_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/comments/36872869"},"html":{"href":"https://github.com/neo4j-contrib/neo4j_doc_manager/pull/2#discussion_r36872869"},"pull_request":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/2","id":42075562,"html_url":"https://github.com/neo4j-contrib/neo4j_doc_manager/pull/2","diff_url":"https://github.com/neo4j-contrib/neo4j_doc_manager/pull/2.diff","patch_url":"https://github.com/neo4j-contrib/neo4j_doc_manager/pull/2.patch","issue_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/issues/2","number":2,"state":"open","locked":false,"title":"Implementing upsert and adding tests","user":{"login":"hannelita","id":506426,"avatar_url":"https://avatars.githubusercontent.com/u/506426?v=3","gravatar_id":"","url":"https://api.github.com/users/hannelita","html_url":"https://github.com/hannelita","followers_url":"https://api.github.com/users/hannelita/followers","following_url":"https://api.github.com/users/hannelita/following{/other_user}","gists_url":"https://api.github.com/users/hannelita/gists{/gist_id}","starred_url":"https://api.github.com/users/hannelita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannelita/subscriptions","organizations_url":"https://api.github.com/users/hannelita/orgs","repos_url":"https://api.github.com/users/hannelita/repos","events_url":"https://api.github.com/users/hannelita/events{/privacy}","received_events_url":"https://api.github.com/users/hannelita/received_events","type":"User","site_admin":false},"body":"Now we have Mongo docs being inserted as nodes with their respective properties in Neo4j\r\n<img width=\"1037\" alt=\"screen shot 2015-08-11 at 12 25 15 am\" src=\"https://cloud.githubusercontent.com/assets/506426/9186237/3253e73a-3fc3-11e5-9adf-837b8019db8d.png\">\r\n\r\n\r\nAll the nodes come labelled as Document:Mongo_collection, as @jexp suggested\r\n","created_at":"2015-08-10T22:53:09Z","updated_at":"2015-08-12T15:22:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0e868cf1b41560869bf0699ea7a52fbab8547fda","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/2/commits","review_comments_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/2/comments","review_comment_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/issues/2/comments","statuses_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/statuses/dce1283592307662b2fe063ffaefe1cc84762a7d","head":{"label":"hannelita:upsert","ref":"upsert","sha":"dce1283592307662b2fe063ffaefe1cc84762a7d","user":{"login":"hannelita","id":506426,"avatar_url":"https://avatars.githubusercontent.com/u/506426?v=3","gravatar_id":"","url":"https://api.github.com/users/hannelita","html_url":"https://github.com/hannelita","followers_url":"https://api.github.com/users/hannelita/followers","following_url":"https://api.github.com/users/hannelita/following{/other_user}","gists_url":"https://api.github.com/users/hannelita/gists{/gist_id}","starred_url":"https://api.github.com/users/hannelita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannelita/subscriptions","organizations_url":"https://api.github.com/users/hannelita/orgs","repos_url":"https://api.github.com/users/hannelita/repos","events_url":"https://api.github.com/users/hannelita/events{/privacy}","received_events_url":"https://api.github.com/users/hannelita/received_events","type":"User","site_admin":false},"repo":{"id":39843964,"name":"neo4j_doc_manager","full_name":"hannelita/neo4j_doc_manager","owner":{"login":"hannelita","id":506426,"avatar_url":"https://avatars.githubusercontent.com/u/506426?v=3","gravatar_id":"","url":"https://api.github.com/users/hannelita","html_url":"https://github.com/hannelita","followers_url":"https://api.github.com/users/hannelita/followers","following_url":"https://api.github.com/users/hannelita/following{/other_user}","gists_url":"https://api.github.com/users/hannelita/gists{/gist_id}","starred_url":"https://api.github.com/users/hannelita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannelita/subscriptions","organizations_url":"https://api.github.com/users/hannelita/orgs","repos_url":"https://api.github.com/users/hannelita/repos","events_url":"https://api.github.com/users/hannelita/events{/privacy}","received_events_url":"https://api.github.com/users/hannelita/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hannelita/neo4j_doc_manager","description":"Doc manager for Neo4j","fork":false,"url":"https://api.github.com/repos/hannelita/neo4j_doc_manager","forks_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/forks","keys_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/teams","hooks_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/hooks","issue_events_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/issues/events{/number}","events_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/events","assignees_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/assignees{/user}","branches_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/branches{/branch}","tags_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/tags","blobs_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/statuses/{sha}","languages_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/languages","stargazers_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/stargazers","contributors_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/contributors","subscribers_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/subscribers","subscription_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/subscription","commits_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/contents/{+path}","compare_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/merges","archive_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/downloads","issues_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/issues{/number}","pulls_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/pulls{/number}","milestones_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/milestones{/number}","notifications_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/labels{/name}","releases_url":"https://api.github.com/repos/hannelita/neo4j_doc_manager/releases{/id}","created_at":"2015-07-28T16:01:05Z","updated_at":"2015-07-28T16:01:34Z","pushed_at":"2015-08-12T10:34:15Z","git_url":"git://github.com/hannelita/neo4j_doc_manager.git","ssh_url":"git@github.com:hannelita/neo4j_doc_manager.git","clone_url":"https://github.com/hannelita/neo4j_doc_manager.git","svn_url":"https://github.com/hannelita/neo4j_doc_manager","homepage":null,"size":125,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"neo4j-contrib:master","ref":"master","sha":"d6f316adb573ff60fa28bfd9e56e994ddb8a2ee5","user":{"login":"neo4j-contrib","id":916372,"avatar_url":"https://avatars.githubusercontent.com/u/916372?v=3","gravatar_id":"","url":"https://api.github.com/users/neo4j-contrib","html_url":"https://github.com/neo4j-contrib","followers_url":"https://api.github.com/users/neo4j-contrib/followers","following_url":"https://api.github.com/users/neo4j-contrib/following{/other_user}","gists_url":"https://api.github.com/users/neo4j-contrib/gists{/gist_id}","starred_url":"https://api.github.com/users/neo4j-contrib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo4j-contrib/subscriptions","organizations_url":"https://api.github.com/users/neo4j-contrib/orgs","repos_url":"https://api.github.com/users/neo4j-contrib/repos","events_url":"https://api.github.com/users/neo4j-contrib/events{/privacy}","received_events_url":"https://api.github.com/users/neo4j-contrib/received_events","type":"Organization","site_admin":false},"repo":{"id":39858685,"name":"neo4j_doc_manager","full_name":"neo4j-contrib/neo4j_doc_manager","owner":{"login":"neo4j-contrib","id":916372,"avatar_url":"https://avatars.githubusercontent.com/u/916372?v=3","gravatar_id":"","url":"https://api.github.com/users/neo4j-contrib","html_url":"https://github.com/neo4j-contrib","followers_url":"https://api.github.com/users/neo4j-contrib/followers","following_url":"https://api.github.com/users/neo4j-contrib/following{/other_user}","gists_url":"https://api.github.com/users/neo4j-contrib/gists{/gist_id}","starred_url":"https://api.github.com/users/neo4j-contrib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo4j-contrib/subscriptions","organizations_url":"https://api.github.com/users/neo4j-contrib/orgs","repos_url":"https://api.github.com/users/neo4j-contrib/repos","events_url":"https://api.github.com/users/neo4j-contrib/events{/privacy}","received_events_url":"https://api.github.com/users/neo4j-contrib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/neo4j-contrib/neo4j_doc_manager","description":"Doc manager for Neo4j","fork":true,"url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager","forks_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/forks","keys_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/teams","hooks_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/hooks","issue_events_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/issues/events{/number}","events_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/events","assignees_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/assignees{/user}","branches_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/branches{/branch}","tags_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/tags","blobs_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/statuses/{sha}","languages_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/languages","stargazers_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/stargazers","contributors_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/contributors","subscribers_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/subscribers","subscription_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/subscription","commits_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/contents/{+path}","compare_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/merges","archive_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/downloads","issues_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/issues{/number}","pulls_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls{/number}","milestones_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/milestones{/number}","notifications_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/labels{/name}","releases_url":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/releases{/id}","created_at":"2015-07-28T21:28:12Z","updated_at":"2015-07-28T21:28:13Z","pushed_at":"2015-08-12T10:34:16Z","git_url":"git://github.com/neo4j-contrib/neo4j_doc_manager.git","ssh_url":"git@github.com:neo4j-contrib/neo4j_doc_manager.git","clone_url":"https://github.com/neo4j-contrib/neo4j_doc_manager.git","svn_url":"https://github.com/neo4j-contrib/neo4j_doc_manager","homepage":null,"size":190,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/2"},"html":{"href":"https://github.com/neo4j-contrib/neo4j_doc_manager/pull/2"},"issue":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/issues/2"},"comments":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/neo4j-contrib/neo4j_doc_manager/statuses/dce1283592307662b2fe063ffaefe1cc84762a7d"}}}}