{"action":"closed","number":419,"pull_request":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/419","id":28533850,"html_url":"https://github.com/strongloop/loopback-datasource-juggler/pull/419","diff_url":"https://github.com/strongloop/loopback-datasource-juggler/pull/419.diff","patch_url":"https://github.com/strongloop/loopback-datasource-juggler/pull/419.patch","issue_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/419","number":419,"state":"closed","locked":false,"title":"use optimized findOrCreate if possible","user":{"login":"clarkorz","id":3261477,"avatar_url":"https://avatars.githubusercontent.com/u/3261477?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkorz","html_url":"https://github.com/clarkorz","followers_url":"https://api.github.com/users/clarkorz/followers","following_url":"https://api.github.com/users/clarkorz/following{/other_user}","gists_url":"https://api.github.com/users/clarkorz/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkorz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkorz/subscriptions","organizations_url":"https://api.github.com/users/clarkorz/orgs","repos_url":"https://api.github.com/users/clarkorz/repos","events_url":"https://api.github.com/users/clarkorz/events{/privacy}","received_events_url":"https://api.github.com/users/clarkorz/received_events","type":"User","site_admin":false},"body":"When using mongodb as database, I often use the native `findAndModify()` to perform a `find or create` (using `$setOnInsert` and `upsert` option). Since `findAndModify()` is an atomic operation, it won't cause conflict in some cases.\r\n\r\nThis PR tests that if the `connector` support `findOrCreate`, and if so then use it, otherwise `find()` or `create()`.\r\n\r\nThis PR use the new hook system introduced in https://github.com/strongloop/loopback-datasource-juggler/pull/403\r\n\r\nSigned-off-by: Clark Wang <clark.wangs@gmail.com>","created_at":"2015-02-03T08:18:27Z","updated_at":"2015-02-12T04:51:15Z","closed_at":"2015-02-12T04:51:15Z","merged_at":"2015-02-12T04:51:15Z","merge_commit_sha":"98e259af27879ba1ade7d18456fbb760c4c02ec1","assignee":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars.githubusercontent.com/u/540892?v=3","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/419/commits","review_comments_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/419/comments","review_comment_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/comments/{number}","comments_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/419/comments","statuses_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/statuses/0bef56efc01cdf3c30712c936f21ed6b7d6d4185","head":{"label":"clarkorz:featrue/support-connector-findOrCreate","ref":"featrue/support-connector-findOrCreate","sha":"0bef56efc01cdf3c30712c936f21ed6b7d6d4185","user":{"login":"clarkorz","id":3261477,"avatar_url":"https://avatars.githubusercontent.com/u/3261477?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkorz","html_url":"https://github.com/clarkorz","followers_url":"https://api.github.com/users/clarkorz/followers","following_url":"https://api.github.com/users/clarkorz/following{/other_user}","gists_url":"https://api.github.com/users/clarkorz/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkorz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkorz/subscriptions","organizations_url":"https://api.github.com/users/clarkorz/orgs","repos_url":"https://api.github.com/users/clarkorz/repos","events_url":"https://api.github.com/users/clarkorz/events{/privacy}","received_events_url":"https://api.github.com/users/clarkorz/received_events","type":"User","site_admin":false},"repo":{"id":23512345,"name":"loopback-datasource-juggler","full_name":"clarkorz/loopback-datasource-juggler","owner":{"login":"clarkorz","id":3261477,"avatar_url":"https://avatars.githubusercontent.com/u/3261477?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkorz","html_url":"https://github.com/clarkorz","followers_url":"https://api.github.com/users/clarkorz/followers","following_url":"https://api.github.com/users/clarkorz/following{/other_user}","gists_url":"https://api.github.com/users/clarkorz/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkorz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkorz/subscriptions","organizations_url":"https://api.github.com/users/clarkorz/orgs","repos_url":"https://api.github.com/users/clarkorz/repos","events_url":"https://api.github.com/users/clarkorz/events{/privacy}","received_events_url":"https://api.github.com/users/clarkorz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/clarkorz/loopback-datasource-juggler","description":"Connect Loopback to various Data Sources","fork":true,"url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler","forks_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/forks","keys_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/teams","hooks_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/hooks","issue_events_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/issues/events{/number}","events_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/events","assignees_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/assignees{/user}","branches_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/branches{/branch}","tags_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/tags","blobs_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/git/refs{/sha}","trees_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/statuses/{sha}","languages_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/languages","stargazers_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/stargazers","contributors_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/contributors","subscribers_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/subscribers","subscription_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/subscription","commits_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/commits{/sha}","git_commits_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/git/commits{/sha}","comments_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/comments{/number}","issue_comment_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/issues/comments/{number}","contents_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/contents/{+path}","compare_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/merges","archive_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/downloads","issues_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/issues{/number}","pulls_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/pulls{/number}","milestones_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/milestones{/number}","notifications_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/labels{/name}","releases_url":"https://api.github.com/repos/clarkorz/loopback-datasource-juggler/releases{/id}","created_at":"2014-08-31T11:44:15Z","updated_at":"2015-02-03T11:36:36Z","pushed_at":"2015-02-10T03:41:34Z","git_url":"git://github.com/clarkorz/loopback-datasource-juggler.git","ssh_url":"git@github.com:clarkorz/loopback-datasource-juggler.git","clone_url":"https://github.com/clarkorz/loopback-datasource-juggler.git","svn_url":"https://github.com/clarkorz/loopback-datasource-juggler","homepage":"www.strongloop.com","size":4236,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":0,"default_branch":"master"}},"base":{"label":"strongloop:master","ref":"master","sha":"e9c966227dedf06cc3d4a84d5a898329182e0b56","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":10126908,"name":"loopback-datasource-juggler","full_name":"strongloop/loopback-datasource-juggler","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback-datasource-juggler","description":"Connect Loopback to various Data Sources","fork":false,"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler","forks_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/forks","keys_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/events","assignees_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/comments/{number}","contents_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/merges","archive_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/releases{/id}","created_at":"2013-05-17T15:56:04Z","updated_at":"2015-02-12T04:51:15Z","pushed_at":"2015-02-12T04:51:15Z","git_url":"git://github.com/strongloop/loopback-datasource-juggler.git","ssh_url":"git@github.com:strongloop/loopback-datasource-juggler.git","clone_url":"https://github.com/strongloop/loopback-datasource-juggler.git","svn_url":"https://github.com/strongloop/loopback-datasource-juggler","homepage":"www.strongloop.com","size":8531,"stargazers_count":54,"watchers_count":54,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":58,"mirror_url":null,"open_issues_count":73,"forks":58,"open_issues":73,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/419"},"html":{"href":"https://github.com/strongloop/loopback-datasource-juggler/pull/419"},"issue":{"href":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/419"},"comments":{"href":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/419/comments"},"review_comments":{"href":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/419/comments"},"review_comment":{"href":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/pulls/419/commits"},"statuses":{"href":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/statuses/0bef56efc01cdf3c30712c936f21ed6b7d6d4185"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars.githubusercontent.com/u/540892?v=3","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"comments":9,"review_comments":3,"commits":1,"additions":115,"deletions":30,"changed_files":3}}