{"action":"created","comment":{"url":"https://api.github.com/repos/arangodb/arangodb/pulls/comments/173091190","pull_request_review_id":102217832,"id":173091190,"diff_hunk":"@@ -229,3 +236,94 @@ void RestSimpleQueryHandler::allDocumentKeys() {\n   // now run the actual query and handle the result\n   processQuery(s);\n }\n+\n+static void buildExampleQuery(VPackBuilder& result,\n+                              std::string const& cname,\n+                              VPackSlice const& doc,\n+                              size_t skip, size_t limit) {\n+  TRI_ASSERT(doc.isObject());\n+  std::string query = \"FOR doc IN @@collection\";\n+  \n+  result.add(\"bindVars\", VPackValue(VPackValueType::Object));\n+  result.add(\"@collection\", VPackValue(cname));\n+  size_t i = 0;\n+  for (auto pair : VPackObjectIterator(doc, true)) {\n+    std::string key = basics::StringUtils::replace(pair.key.copyString(), \"`\", \"\");\n+    key = basics::StringUtils::join(basics::StringUtils::split(key, \".\"), \"`.`\");\n+    std::string istr = std::to_string(i++);\n+    query.append(\" FILTER doc.`\").append(key).append(\"` == @value\").append(istr);\n+    result.add(std::string(\"value\") + istr, pair.value);\n+  }\n+  result.close();\n+  \n+  if (limit > 0 || skip > 0) {\n+    query.append(\" LIMIT \").append(std::to_string(skip))\n+         .append(\", \").append(limit > 0 ? std::to_string(limit) : \"null\")\n+         .append(\" \");\n+  }\n+  query.append(\" RETURN doc\");\n+  \n+  result.add(\"query\", VPackValue(query));\n+}\n+\n+//////////////////////////////////////////////////////////////////////////////\n+/// @brief return a cursor with all documents matching the example\n+//////////////////////////////////////////////////////////////////////////////\n+\n+void RestSimpleQueryHandler::byExample() {\n+  bool parseSuccess = true;\n+  std::shared_ptr<VPackBuilder> parsedBody =\n+  parseVelocyPackBody(parseSuccess);\n+  if (!parseSuccess) {\n+    // error message generated in parseVelocyPackBody\n+    return;\n+  }\n+  VPackSlice body = parsedBody.get()->slice();\n+  if (!body.isObject() || !body.hasKey(\"example\") ||\n+      !body.get(\"example\").isObject()) {\n+    generateError(ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER);\n+    return;\n+  }\n+  \n+  size_t skip = basics::VelocyPackHelper::getNumericValue(body, \"skip\", 0);\n+  size_t limit = basics::VelocyPackHelper::getNumericValue(body, \"limit\", 0);\n+  size_t batchSize = basics::VelocyPackHelper::getNumericValue(body, \"batchSize\", 0);\n+  VPackSlice example = body.get(\"example\");\n+  \n+  std::string cname;\n+  if (body.isObject() && body.hasKey(\"collection\")) {\n+    VPackSlice const value = body.get(\"collection\");\n+    if (value.isString()) {\n+      cname = value.copyString();\n+    }\n+    cname = value.copyString();","path":"arangod/RestHandler/RestSimpleQueryHandler.cpp","position":96,"original_position":96,"commit_id":"0048c19eb77419517beceb04382b09eced91b683","original_commit_id":"0048c19eb77419517beceb04382b09eced91b683","user":{"login":"jsteemann","id":1423118,"avatar_url":"https://avatars0.githubusercontent.com/u/1423118?v=4","gravatar_id":"","url":"https://api.github.com/users/jsteemann","html_url":"https://github.com/jsteemann","followers_url":"https://api.github.com/users/jsteemann/followers","following_url":"https://api.github.com/users/jsteemann/following{/other_user}","gists_url":"https://api.github.com/users/jsteemann/gists{/gist_id}","starred_url":"https://api.github.com/users/jsteemann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsteemann/subscriptions","organizations_url":"https://api.github.com/users/jsteemann/orgs","repos_url":"https://api.github.com/users/jsteemann/repos","events_url":"https://api.github.com/users/jsteemann/events{/privacy}","received_events_url":"https://api.github.com/users/jsteemann/received_events","type":"User","site_admin":false},"body":"not convinced here...","created_at":"2018-03-08T08:29:52Z","updated_at":"2018-03-08T08:30:46Z","html_url":"https://github.com/arangodb/arangodb/pull/4779#discussion_r173091190","pull_request_url":"https://api.github.com/repos/arangodb/arangodb/pulls/4779","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/arangodb/arangodb/pulls/comments/173091190"},"html":{"href":"https://github.com/arangodb/arangodb/pull/4779#discussion_r173091190"},"pull_request":{"href":"https://api.github.com/repos/arangodb/arangodb/pulls/4779"}}},"pull_request":{"url":"https://api.github.com/repos/arangodb/arangodb/pulls/4779","id":173616706,"html_url":"https://github.com/arangodb/arangodb/pull/4779","diff_url":"https://github.com/arangodb/arangodb/pull/4779.diff","patch_url":"https://github.com/arangodb/arangodb/pull/4779.patch","issue_url":"https://api.github.com/repos/arangodb/arangodb/issues/4779","number":4779,"state":"open","locked":false,"title":"Replace /_api/simple/by-example","user":{"login":"graetzer","id":865417,"avatar_url":"https://avatars3.githubusercontent.com/u/865417?v=4","gravatar_id":"","url":"https://api.github.com/users/graetzer","html_url":"https://github.com/graetzer","followers_url":"https://api.github.com/users/graetzer/followers","following_url":"https://api.github.com/users/graetzer/following{/other_user}","gists_url":"https://api.github.com/users/graetzer/gists{/gist_id}","starred_url":"https://api.github.com/users/graetzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graetzer/subscriptions","organizations_url":"https://api.github.com/users/graetzer/orgs","repos_url":"https://api.github.com/users/graetzer/repos","events_url":"https://api.github.com/users/graetzer/events{/privacy}","received_events_url":"https://api.github.com/users/graetzer/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-08T00:54:54Z","updated_at":"2018-03-08T08:30:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a281eaf0d7474b7b341af96a0eb5ea679a31305c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/arangodb/arangodb/milestones/82","html_url":"https://github.com/arangodb/arangodb/milestone/82","labels_url":"https://api.github.com/repos/arangodb/arangodb/milestones/82/labels","id":2963125,"number":82,"title":"devel","description":null,"creator":{"login":"fceller","id":392005,"avatar_url":"https://avatars2.githubusercontent.com/u/392005?v=4","gravatar_id":"","url":"https://api.github.com/users/fceller","html_url":"https://github.com/fceller","followers_url":"https://api.github.com/users/fceller/followers","following_url":"https://api.github.com/users/fceller/following{/other_user}","gists_url":"https://api.github.com/users/fceller/gists{/gist_id}","starred_url":"https://api.github.com/users/fceller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fceller/subscriptions","organizations_url":"https://api.github.com/users/fceller/orgs","repos_url":"https://api.github.com/users/fceller/repos","events_url":"https://api.github.com/users/fceller/events{/privacy}","received_events_url":"https://api.github.com/users/fceller/received_events","type":"User","site_admin":false},"open_issues":27,"closed_issues":214,"state":"open","created_at":"2017-12-06T23:27:12Z","updated_at":"2018-03-08T08:18:41Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/arangodb/arangodb/pulls/4779/commits","review_comments_url":"https://api.github.com/repos/arangodb/arangodb/pulls/4779/comments","review_comment_url":"https://api.github.com/repos/arangodb/arangodb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/arangodb/arangodb/issues/4779/comments","statuses_url":"https://api.github.com/repos/arangodb/arangodb/statuses/0048c19eb77419517beceb04382b09eced91b683","head":{"label":"arangodb:feature/v8bleach-by-example","ref":"feature/v8bleach-by-example","sha":"0048c19eb77419517beceb04382b09eced91b683","user":{"login":"arangodb","id":5547849,"avatar_url":"https://avatars0.githubusercontent.com/u/5547849?v=4","gravatar_id":"","url":"https://api.github.com/users/arangodb","html_url":"https://github.com/arangodb","followers_url":"https://api.github.com/users/arangodb/followers","following_url":"https://api.github.com/users/arangodb/following{/other_user}","gists_url":"https://api.github.com/users/arangodb/gists{/gist_id}","starred_url":"https://api.github.com/users/arangodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arangodb/subscriptions","organizations_url":"https://api.github.com/users/arangodb/orgs","repos_url":"https://api.github.com/users/arangodb/repos","events_url":"https://api.github.com/users/arangodb/events{/privacy}","received_events_url":"https://api.github.com/users/arangodb/received_events","type":"Organization","site_admin":false},"repo":{"id":2649214,"name":"arangodb","full_name":"arangodb/arangodb","owner":{"login":"arangodb","id":5547849,"avatar_url":"https://avatars0.githubusercontent.com/u/5547849?v=4","gravatar_id":"","url":"https://api.github.com/users/arangodb","html_url":"https://github.com/arangodb","followers_url":"https://api.github.com/users/arangodb/followers","following_url":"https://api.github.com/users/arangodb/following{/other_user}","gists_url":"https://api.github.com/users/arangodb/gists{/gist_id}","starred_url":"https://api.github.com/users/arangodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arangodb/subscriptions","organizations_url":"https://api.github.com/users/arangodb/orgs","repos_url":"https://api.github.com/users/arangodb/repos","events_url":"https://api.github.com/users/arangodb/events{/privacy}","received_events_url":"https://api.github.com/users/arangodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/arangodb/arangodb","description":"🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.","fork":false,"url":"https://api.github.com/repos/arangodb/arangodb","forks_url":"https://api.github.com/repos/arangodb/arangodb/forks","keys_url":"https://api.github.com/repos/arangodb/arangodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arangodb/arangodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arangodb/arangodb/teams","hooks_url":"https://api.github.com/repos/arangodb/arangodb/hooks","issue_events_url":"https://api.github.com/repos/arangodb/arangodb/issues/events{/number}","events_url":"https://api.github.com/repos/arangodb/arangodb/events","assignees_url":"https://api.github.com/repos/arangodb/arangodb/assignees{/user}","branches_url":"https://api.github.com/repos/arangodb/arangodb/branches{/branch}","tags_url":"https://api.github.com/repos/arangodb/arangodb/tags","blobs_url":"https://api.github.com/repos/arangodb/arangodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arangodb/arangodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arangodb/arangodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/arangodb/arangodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arangodb/arangodb/statuses/{sha}","languages_url":"https://api.github.com/repos/arangodb/arangodb/languages","stargazers_url":"https://api.github.com/repos/arangodb/arangodb/stargazers","contributors_url":"https://api.github.com/repos/arangodb/arangodb/contributors","subscribers_url":"https://api.github.com/repos/arangodb/arangodb/subscribers","subscription_url":"https://api.github.com/repos/arangodb/arangodb/subscription","commits_url":"https://api.github.com/repos/arangodb/arangodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/arangodb/arangodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/arangodb/arangodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/arangodb/arangodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/arangodb/arangodb/contents/{+path}","compare_url":"https://api.github.com/repos/arangodb/arangodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arangodb/arangodb/merges","archive_url":"https://api.github.com/repos/arangodb/arangodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arangodb/arangodb/downloads","issues_url":"https://api.github.com/repos/arangodb/arangodb/issues{/number}","pulls_url":"https://api.github.com/repos/arangodb/arangodb/pulls{/number}","milestones_url":"https://api.github.com/repos/arangodb/arangodb/milestones{/number}","notifications_url":"https://api.github.com/repos/arangodb/arangodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arangodb/arangodb/labels{/name}","releases_url":"https://api.github.com/repos/arangodb/arangodb/releases{/id}","deployments_url":"https://api.github.com/repos/arangodb/arangodb/deployments","created_at":"2011-10-26T06:42:00Z","updated_at":"2018-03-08T07:49:47Z","pushed_at":"2018-03-08T08:19:17Z","git_url":"git://github.com/arangodb/arangodb.git","ssh_url":"git@github.com:arangodb/arangodb.git","clone_url":"https://github.com/arangodb/arangodb.git","svn_url":"https://github.com/arangodb/arangodb","homepage":"https://www.arangodb.com","size":811297,"stargazers_count":5271,"watchers_count":5271,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":399,"mirror_url":null,"archived":false,"open_issues_count":394,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":399,"open_issues":394,"watchers":5271,"default_branch":"devel"}},"base":{"label":"arangodb:devel","ref":"devel","sha":"edaeeaff6a6051477b1a6403fd26098bfdab15aa","user":{"login":"arangodb","id":5547849,"avatar_url":"https://avatars0.githubusercontent.com/u/5547849?v=4","gravatar_id":"","url":"https://api.github.com/users/arangodb","html_url":"https://github.com/arangodb","followers_url":"https://api.github.com/users/arangodb/followers","following_url":"https://api.github.com/users/arangodb/following{/other_user}","gists_url":"https://api.github.com/users/arangodb/gists{/gist_id}","starred_url":"https://api.github.com/users/arangodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arangodb/subscriptions","organizations_url":"https://api.github.com/users/arangodb/orgs","repos_url":"https://api.github.com/users/arangodb/repos","events_url":"https://api.github.com/users/arangodb/events{/privacy}","received_events_url":"https://api.github.com/users/arangodb/received_events","type":"Organization","site_admin":false},"repo":{"id":2649214,"name":"arangodb","full_name":"arangodb/arangodb","owner":{"login":"arangodb","id":5547849,"avatar_url":"https://avatars0.githubusercontent.com/u/5547849?v=4","gravatar_id":"","url":"https://api.github.com/users/arangodb","html_url":"https://github.com/arangodb","followers_url":"https://api.github.com/users/arangodb/followers","following_url":"https://api.github.com/users/arangodb/following{/other_user}","gists_url":"https://api.github.com/users/arangodb/gists{/gist_id}","starred_url":"https://api.github.com/users/arangodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arangodb/subscriptions","organizations_url":"https://api.github.com/users/arangodb/orgs","repos_url":"https://api.github.com/users/arangodb/repos","events_url":"https://api.github.com/users/arangodb/events{/privacy}","received_events_url":"https://api.github.com/users/arangodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/arangodb/arangodb","description":"🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.","fork":false,"url":"https://api.github.com/repos/arangodb/arangodb","forks_url":"https://api.github.com/repos/arangodb/arangodb/forks","keys_url":"https://api.github.com/repos/arangodb/arangodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arangodb/arangodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arangodb/arangodb/teams","hooks_url":"https://api.github.com/repos/arangodb/arangodb/hooks","issue_events_url":"https://api.github.com/repos/arangodb/arangodb/issues/events{/number}","events_url":"https://api.github.com/repos/arangodb/arangodb/events","assignees_url":"https://api.github.com/repos/arangodb/arangodb/assignees{/user}","branches_url":"https://api.github.com/repos/arangodb/arangodb/branches{/branch}","tags_url":"https://api.github.com/repos/arangodb/arangodb/tags","blobs_url":"https://api.github.com/repos/arangodb/arangodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arangodb/arangodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arangodb/arangodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/arangodb/arangodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arangodb/arangodb/statuses/{sha}","languages_url":"https://api.github.com/repos/arangodb/arangodb/languages","stargazers_url":"https://api.github.com/repos/arangodb/arangodb/stargazers","contributors_url":"https://api.github.com/repos/arangodb/arangodb/contributors","subscribers_url":"https://api.github.com/repos/arangodb/arangodb/subscribers","subscription_url":"https://api.github.com/repos/arangodb/arangodb/subscription","commits_url":"https://api.github.com/repos/arangodb/arangodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/arangodb/arangodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/arangodb/arangodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/arangodb/arangodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/arangodb/arangodb/contents/{+path}","compare_url":"https://api.github.com/repos/arangodb/arangodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arangodb/arangodb/merges","archive_url":"https://api.github.com/repos/arangodb/arangodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arangodb/arangodb/downloads","issues_url":"https://api.github.com/repos/arangodb/arangodb/issues{/number}","pulls_url":"https://api.github.com/repos/arangodb/arangodb/pulls{/number}","milestones_url":"https://api.github.com/repos/arangodb/arangodb/milestones{/number}","notifications_url":"https://api.github.com/repos/arangodb/arangodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arangodb/arangodb/labels{/name}","releases_url":"https://api.github.com/repos/arangodb/arangodb/releases{/id}","deployments_url":"https://api.github.com/repos/arangodb/arangodb/deployments","created_at":"2011-10-26T06:42:00Z","updated_at":"2018-03-08T07:49:47Z","pushed_at":"2018-03-08T08:19:17Z","git_url":"git://github.com/arangodb/arangodb.git","ssh_url":"git@github.com:arangodb/arangodb.git","clone_url":"https://github.com/arangodb/arangodb.git","svn_url":"https://github.com/arangodb/arangodb","homepage":"https://www.arangodb.com","size":811297,"stargazers_count":5271,"watchers_count":5271,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":399,"mirror_url":null,"archived":false,"open_issues_count":394,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":399,"open_issues":394,"watchers":5271,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/arangodb/arangodb/pulls/4779"},"html":{"href":"https://github.com/arangodb/arangodb/pull/4779"},"issue":{"href":"https://api.github.com/repos/arangodb/arangodb/issues/4779"},"comments":{"href":"https://api.github.com/repos/arangodb/arangodb/issues/4779/comments"},"review_comments":{"href":"https://api.github.com/repos/arangodb/arangodb/pulls/4779/comments"},"review_comment":{"href":"https://api.github.com/repos/arangodb/arangodb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/arangodb/arangodb/pulls/4779/commits"},"statuses":{"href":"https://api.github.com/repos/arangodb/arangodb/statuses/0048c19eb77419517beceb04382b09eced91b683"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jsteemann"}}