service/service_instance.go
func DeleteInstance(si *ServiceInstance, evt *event.Event, requestID string) error {
	if len(si.Apps) > 0 {
		return ErrServiceInstanceBound
	}
	s, err := Get(si.ServiceName)
	if err != nil {
		return err
	}
	endpoint, err := s.getClient("production")
	if err == nil {
		endpoint.Destroy(si, evt, requestID)
	}
	conn, err := db.Conn()
	if err != nil {
		return err
	}
	defer conn.Close()
	return conn.ServiceInstances().Remove(bson.M{"name": si.Name, "service_name": si.ServiceName})
}
func DeleteInstance(si *ServiceInstance, evt *event.Event, requestID string) error {
	if len(si.Apps) > 0 {
		return ErrServiceInstanceBound
	}
	s, err := Get(si.ServiceName)
	if err != nil {
		return err
	}
	endpoint, err := s.getClient("production")
	if err == nil {
		endpoint.Destroy(si, evt, requestID)
	}
	conn, err := db.Conn()
	if err != nil {
		return err
	}
	defer conn.Close()
	return conn.ServiceInstances().Remove(bson.M{"name": si.Name, "service_name": si.ServiceName})
}
// DeleteInstance deletes the service instance from the database.