def resolve_foreign_objects(object, map)
      object.foreign_objects.each do |property|
        value = object[property]
        if value.present?
          foreign_object = ForeignObject.new(value)
          resolve_foreign_keys(foreign_object, map)
          document = connection.find(foreign_object.to_h)

          if document
            object["#{property}_id"] = document['_id']
          else
            raise Errors::MissingDatabaseIdError, "couldn't resolve foreign object: #{property} #{value}"
          end
        end
      end
    end
def resolve_foreign_objects(object, map)
      object.foreign_objects.each do |property|
        value = object[property]
        if value.present?
          foreign_object = ForeignObject.new(value)
          resolve_foreign_keys(foreign_object, map)
          document = connection.find(foreign_object.to_h)

          if document
            object["#{property}_id"] = document['_id']
          else
            raise Errors::MissingDatabaseIdError, "couldn't resolve foreign object: #{property} #{value}"
          end
        end
      end
    end
Resolves an object's foreign objects to database IDs.

 @param [Object] object an object
 @param [Hash] a map from object ID to database ID
 @raises [Pupa::Errors::MissingDatabaseIdError] if a foreign object cannot
   be resolved