{"action":"created","comment":{"url":"https://api.github.com/repos/prisma/prisma/pulls/comments/212660173","pull_request_review_id":149343217,"id":212660173,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjY2MDE3Mw==","diff_hunk":"@@ -0,0 +1,75 @@\n+package com.prisma.api.connector.mongo.impl\n+\n+import com.prisma.api.connector._\n+import com.prisma.api.connector.mongo.database.FilterConditionBuilder\n+import com.prisma.api.connector.mongo.extensions.DocumentToRoot\n+import com.prisma.api.connector.mongo.extensions.NodeSelectorBsonTransformer.WhereToBson\n+import com.prisma.gc_values._\n+import com.prisma.shared.models._\n+import org.mongodb.scala.model.Filters\n+import org.mongodb.scala.{Document, MongoClient, MongoCollection}\n+\n+import scala.concurrent.{ExecutionContext, Future}\n+\n+case class MongoDataResolver(project: Project, client: MongoClient)(implicit ec: ExecutionContext) extends DataResolver with FilterConditionBuilder {\n+  val database = client.getDatabase(project.id)\n+\n+  override def getModelForGlobalId(globalId: CuidGCValue): Future[Option[Model]] = {\n+    val outer = project.models.map { model =>\n+      val collection: MongoCollection[Document] = database.getCollection(model.name)\n+      collection.find(Filters.eq(\"_id\", globalId.value)).collect().toFuture.map { results: Seq[Document] =>\n+        if (results.nonEmpty) Vector(model) else Vector.empty\n+      }\n+    }\n+\n+    val sequence: Future[List[Vector[Model]]] = Future.sequence(outer)\n+\n+    sequence.map(_.flatten.headOption)\n+  }\n+\n+  //Fixme this does not use selected fields\n+  override def getNodeByWhere(where: NodeSelector, selectedFields: SelectedFields): Future[Option[PrismaNode]] = {\n+    val collection: MongoCollection[Document] = database.getCollection(where.model.dbName)\n+    collection.find(WhereToBson(where)).collect().toFuture.map { results: Seq[Document] =>\n+      results.headOption.map { result =>\n+        val root = DocumentToRoot(where.model, result)\n+        PrismaNode(root.idField, root, Some(where.model.name))\n+      }\n+    }\n+  }\n+\n+  override def countByTable(table: String, whereFilter: Option[Filter]): Future[Int] = {\n+    database.getCollection(table).countDocuments(buildConditionForFilter(whereFilter)).toFuture.map(_.toInt)\n+  }\n+\n+  // Fixme this does not use selected fields\n+  override def getNodes(model: Model, args: Option[QueryArguments], selectedFields: SelectedFields): Future[ResolverResult[PrismaNode]] = {\n+    val collection: MongoCollection[Document] = database.getCollection(model.dbName)\n+    val filter = args match {\n+      case Some(arg) => arg.filter\n+      case None      => None\n+    }\n+\n+    val mongoFilter = buildConditionForFilter(filter)\n+\n+    val nodes: Future[Seq[PrismaNode]] = collection.find(mongoFilter).collect().toFuture.map { results: Seq[Document] =>\n+      results.map { result =>\n+        val root = DocumentToRoot(model, result)\n+        PrismaNode(root.idField, root, Some(model.name))\n+      }\n+    }\n+    nodes.map(n => ResolverResult[PrismaNode](n.toVector, false, false, None))\n+  }\n+\n+  //these are only used for relations between non-embedded types\n+  override def getRelatedNodes(fromField: RelationField,\n+                               fromNodeIds: Vector[IdGCValue],\n+                               args: Option[QueryArguments],\n+                               selectedFields: SelectedFields): Future[Vector[ResolverResult[PrismaNodeWithParent]]] = ???","path":"server/connectors/api-connector-mongo/src/main/scala/com/prisma/api/connector/mongo/impl/MongoDataResolver.scala","position":68,"original_position":68,"commit_id":"240888df182b95fda4c655e3939306c65a88b3b6","original_commit_id":"240888df182b95fda4c655e3939306c65a88b3b6","user":{"login":"codacy-bot","id":19940114,"node_id":"MDQ6VXNlcjE5OTQwMTE0","avatar_url":"https://avatars1.githubusercontent.com/u/19940114?v=4","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://app.codacy.com/assets/images/favicon.png) Issue found: [Usage of ??? operator](https://app.codacy.com/app/graphcool/prisma/pullRequest?prid=2002555)","created_at":"2018-08-24T15:08:53Z","updated_at":"2018-08-24T15:08:53Z","html_url":"https://github.com/prisma/prisma/pull/2883#discussion_r212660173","pull_request_url":"https://api.github.com/repos/prisma/prisma/pulls/2883","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/prisma/prisma/pulls/comments/212660173"},"html":{"href":"https://github.com/prisma/prisma/pull/2883#discussion_r212660173"},"pull_request":{"href":"https://api.github.com/repos/prisma/prisma/pulls/2883"}}},"pull_request":{"url":"https://api.github.com/repos/prisma/prisma/pulls/2883","id":206375310,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2Mzc1MzEw","html_url":"https://github.com/prisma/prisma/pull/2883","diff_url":"https://github.com/prisma/prisma/pull/2883.diff","patch_url":"https://github.com/prisma/prisma/pull/2883.patch","issue_url":"https://api.github.com/repos/prisma/prisma/issues/2883","number":2883,"state":"open","locked":false,"title":"[WIP] Mongo db connector","user":{"login":"do4gr","id":16278407,"node_id":"MDQ6VXNlcjE2Mjc4NDA3","avatar_url":"https://avatars2.githubusercontent.com/u/16278407?v=4","gravatar_id":"","url":"https://api.github.com/users/do4gr","html_url":"https://github.com/do4gr","followers_url":"https://api.github.com/users/do4gr/followers","following_url":"https://api.github.com/users/do4gr/following{/other_user}","gists_url":"https://api.github.com/users/do4gr/gists{/gist_id}","starred_url":"https://api.github.com/users/do4gr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/do4gr/subscriptions","organizations_url":"https://api.github.com/users/do4gr/orgs","repos_url":"https://api.github.com/users/do4gr/repos","events_url":"https://api.github.com/users/do4gr/events{/privacy}","received_events_url":"https://api.github.com/users/do4gr/received_events","type":"User","site_admin":false},"body":"Breaking change: Removes the NestedDeleteInputType from a Parent when the child is required. This operation would always be rejected anyways. We already did so for disconnect a while ago but forgot about delete.","created_at":"2018-08-06T11:56:35Z","updated_at":"2018-08-24T15:08:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a58644041acf3fd2eae06d5f7a4a5ac1bc03dd3c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/prisma/prisma/pulls/2883/commits","review_comments_url":"https://api.github.com/repos/prisma/prisma/pulls/2883/comments","review_comment_url":"https://api.github.com/repos/prisma/prisma/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prisma/prisma/issues/2883/comments","statuses_url":"https://api.github.com/repos/prisma/prisma/statuses/240888df182b95fda4c655e3939306c65a88b3b6","head":{"label":"prisma:MongoDBConnector","ref":"MongoDBConnector","sha":"240888df182b95fda4c655e3939306c65a88b3b6","user":{"login":"prisma","id":17219288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3MjE5Mjg4","avatar_url":"https://avatars0.githubusercontent.com/u/17219288?v=4","gravatar_id":"","url":"https://api.github.com/users/prisma","html_url":"https://github.com/prisma","followers_url":"https://api.github.com/users/prisma/followers","following_url":"https://api.github.com/users/prisma/following{/other_user}","gists_url":"https://api.github.com/users/prisma/gists{/gist_id}","starred_url":"https://api.github.com/users/prisma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prisma/subscriptions","organizations_url":"https://api.github.com/users/prisma/orgs","repos_url":"https://api.github.com/users/prisma/repos","events_url":"https://api.github.com/users/prisma/events{/privacy}","received_events_url":"https://api.github.com/users/prisma/received_events","type":"Organization","site_admin":false},"repo":{"id":69164196,"node_id":"MDEwOlJlcG9zaXRvcnk2OTE2NDE5Ng==","name":"prisma","full_name":"prisma/prisma","owner":{"login":"prisma","id":17219288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3MjE5Mjg4","avatar_url":"https://avatars0.githubusercontent.com/u/17219288?v=4","gravatar_id":"","url":"https://api.github.com/users/prisma","html_url":"https://github.com/prisma","followers_url":"https://api.github.com/users/prisma/followers","following_url":"https://api.github.com/users/prisma/following{/other_user}","gists_url":"https://api.github.com/users/prisma/gists{/gist_id}","starred_url":"https://api.github.com/users/prisma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prisma/subscriptions","organizations_url":"https://api.github.com/users/prisma/orgs","repos_url":"https://api.github.com/users/prisma/repos","events_url":"https://api.github.com/users/prisma/events{/privacy}","received_events_url":"https://api.github.com/users/prisma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prisma/prisma","description":"⚡️ Prisma turns your database into a realtime GraphQL API","fork":false,"url":"https://api.github.com/repos/prisma/prisma","forks_url":"https://api.github.com/repos/prisma/prisma/forks","keys_url":"https://api.github.com/repos/prisma/prisma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prisma/prisma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prisma/prisma/teams","hooks_url":"https://api.github.com/repos/prisma/prisma/hooks","issue_events_url":"https://api.github.com/repos/prisma/prisma/issues/events{/number}","events_url":"https://api.github.com/repos/prisma/prisma/events","assignees_url":"https://api.github.com/repos/prisma/prisma/assignees{/user}","branches_url":"https://api.github.com/repos/prisma/prisma/branches{/branch}","tags_url":"https://api.github.com/repos/prisma/prisma/tags","blobs_url":"https://api.github.com/repos/prisma/prisma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prisma/prisma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prisma/prisma/git/refs{/sha}","trees_url":"https://api.github.com/repos/prisma/prisma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prisma/prisma/statuses/{sha}","languages_url":"https://api.github.com/repos/prisma/prisma/languages","stargazers_url":"https://api.github.com/repos/prisma/prisma/stargazers","contributors_url":"https://api.github.com/repos/prisma/prisma/contributors","subscribers_url":"https://api.github.com/repos/prisma/prisma/subscribers","subscription_url":"https://api.github.com/repos/prisma/prisma/subscription","commits_url":"https://api.github.com/repos/prisma/prisma/commits{/sha}","git_commits_url":"https://api.github.com/repos/prisma/prisma/git/commits{/sha}","comments_url":"https://api.github.com/repos/prisma/prisma/comments{/number}","issue_comment_url":"https://api.github.com/repos/prisma/prisma/issues/comments{/number}","contents_url":"https://api.github.com/repos/prisma/prisma/contents/{+path}","compare_url":"https://api.github.com/repos/prisma/prisma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prisma/prisma/merges","archive_url":"https://api.github.com/repos/prisma/prisma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prisma/prisma/downloads","issues_url":"https://api.github.com/repos/prisma/prisma/issues{/number}","pulls_url":"https://api.github.com/repos/prisma/prisma/pulls{/number}","milestones_url":"https://api.github.com/repos/prisma/prisma/milestones{/number}","notifications_url":"https://api.github.com/repos/prisma/prisma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prisma/prisma/labels{/name}","releases_url":"https://api.github.com/repos/prisma/prisma/releases{/id}","deployments_url":"https://api.github.com/repos/prisma/prisma/deployments","created_at":"2016-09-25T12:54:40Z","updated_at":"2018-08-24T14:38:27Z","pushed_at":"2018-08-24T15:05:07Z","git_url":"git://github.com/prisma/prisma.git","ssh_url":"git@github.com:prisma/prisma.git","clone_url":"https://github.com/prisma/prisma.git","svn_url":"https://github.com/prisma/prisma","homepage":"https://www.prisma.io/","size":20081,"stargazers_count":9856,"watchers_count":9856,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":546,"mirror_url":null,"archived":false,"open_issues_count":404,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":546,"open_issues":404,"watchers":9856,"default_branch":"master"}},"base":{"label":"prisma:alpha","ref":"alpha","sha":"03d2491a9d55cdbe8bea6b0f16b6cc2847f3667c","user":{"login":"prisma","id":17219288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3MjE5Mjg4","avatar_url":"https://avatars0.githubusercontent.com/u/17219288?v=4","gravatar_id":"","url":"https://api.github.com/users/prisma","html_url":"https://github.com/prisma","followers_url":"https://api.github.com/users/prisma/followers","following_url":"https://api.github.com/users/prisma/following{/other_user}","gists_url":"https://api.github.com/users/prisma/gists{/gist_id}","starred_url":"https://api.github.com/users/prisma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prisma/subscriptions","organizations_url":"https://api.github.com/users/prisma/orgs","repos_url":"https://api.github.com/users/prisma/repos","events_url":"https://api.github.com/users/prisma/events{/privacy}","received_events_url":"https://api.github.com/users/prisma/received_events","type":"Organization","site_admin":false},"repo":{"id":69164196,"node_id":"MDEwOlJlcG9zaXRvcnk2OTE2NDE5Ng==","name":"prisma","full_name":"prisma/prisma","owner":{"login":"prisma","id":17219288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3MjE5Mjg4","avatar_url":"https://avatars0.githubusercontent.com/u/17219288?v=4","gravatar_id":"","url":"https://api.github.com/users/prisma","html_url":"https://github.com/prisma","followers_url":"https://api.github.com/users/prisma/followers","following_url":"https://api.github.com/users/prisma/following{/other_user}","gists_url":"https://api.github.com/users/prisma/gists{/gist_id}","starred_url":"https://api.github.com/users/prisma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prisma/subscriptions","organizations_url":"https://api.github.com/users/prisma/orgs","repos_url":"https://api.github.com/users/prisma/repos","events_url":"https://api.github.com/users/prisma/events{/privacy}","received_events_url":"https://api.github.com/users/prisma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prisma/prisma","description":"⚡️ Prisma turns your database into a realtime GraphQL API","fork":false,"url":"https://api.github.com/repos/prisma/prisma","forks_url":"https://api.github.com/repos/prisma/prisma/forks","keys_url":"https://api.github.com/repos/prisma/prisma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prisma/prisma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prisma/prisma/teams","hooks_url":"https://api.github.com/repos/prisma/prisma/hooks","issue_events_url":"https://api.github.com/repos/prisma/prisma/issues/events{/number}","events_url":"https://api.github.com/repos/prisma/prisma/events","assignees_url":"https://api.github.com/repos/prisma/prisma/assignees{/user}","branches_url":"https://api.github.com/repos/prisma/prisma/branches{/branch}","tags_url":"https://api.github.com/repos/prisma/prisma/tags","blobs_url":"https://api.github.com/repos/prisma/prisma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prisma/prisma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prisma/prisma/git/refs{/sha}","trees_url":"https://api.github.com/repos/prisma/prisma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prisma/prisma/statuses/{sha}","languages_url":"https://api.github.com/repos/prisma/prisma/languages","stargazers_url":"https://api.github.com/repos/prisma/prisma/stargazers","contributors_url":"https://api.github.com/repos/prisma/prisma/contributors","subscribers_url":"https://api.github.com/repos/prisma/prisma/subscribers","subscription_url":"https://api.github.com/repos/prisma/prisma/subscription","commits_url":"https://api.github.com/repos/prisma/prisma/commits{/sha}","git_commits_url":"https://api.github.com/repos/prisma/prisma/git/commits{/sha}","comments_url":"https://api.github.com/repos/prisma/prisma/comments{/number}","issue_comment_url":"https://api.github.com/repos/prisma/prisma/issues/comments{/number}","contents_url":"https://api.github.com/repos/prisma/prisma/contents/{+path}","compare_url":"https://api.github.com/repos/prisma/prisma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prisma/prisma/merges","archive_url":"https://api.github.com/repos/prisma/prisma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prisma/prisma/downloads","issues_url":"https://api.github.com/repos/prisma/prisma/issues{/number}","pulls_url":"https://api.github.com/repos/prisma/prisma/pulls{/number}","milestones_url":"https://api.github.com/repos/prisma/prisma/milestones{/number}","notifications_url":"https://api.github.com/repos/prisma/prisma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prisma/prisma/labels{/name}","releases_url":"https://api.github.com/repos/prisma/prisma/releases{/id}","deployments_url":"https://api.github.com/repos/prisma/prisma/deployments","created_at":"2016-09-25T12:54:40Z","updated_at":"2018-08-24T14:38:27Z","pushed_at":"2018-08-24T15:05:07Z","git_url":"git://github.com/prisma/prisma.git","ssh_url":"git@github.com:prisma/prisma.git","clone_url":"https://github.com/prisma/prisma.git","svn_url":"https://github.com/prisma/prisma","homepage":"https://www.prisma.io/","size":20081,"stargazers_count":9856,"watchers_count":9856,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":546,"mirror_url":null,"archived":false,"open_issues_count":404,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":546,"open_issues":404,"watchers":9856,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prisma/prisma/pulls/2883"},"html":{"href":"https://github.com/prisma/prisma/pull/2883"},"issue":{"href":"https://api.github.com/repos/prisma/prisma/issues/2883"},"comments":{"href":"https://api.github.com/repos/prisma/prisma/issues/2883/comments"},"review_comments":{"href":"https://api.github.com/repos/prisma/prisma/pulls/2883/comments"},"review_comment":{"href":"https://api.github.com/repos/prisma/prisma/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prisma/prisma/pulls/2883/commits"},"statuses":{"href":"https://api.github.com/repos/prisma/prisma/statuses/240888df182b95fda4c655e3939306c65a88b3b6"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"codacy-bot"}}