civicrm/civicrm-core — pull request #1205 by totten (2013-07-19 23:32:10+00:00)
Title: CRM-12943 - Add findCreate() helper

Several of screens in the "Job" tab need to fetch a single record using an FK (e.g. "find HRJobPay by job_id") -- and, if none is found, then it creates a new record.

This provides DRY.

Note: I tried to use Backbone.Model.fetch() instead of Backbone.Collection.fetch(). However, fetch() had two issues: it's generally geared towards "fetch by id", and there' specificiation for how to report "non-existence" -- you either have "success" or "error" (with an unstructured error blob).