func InvokeAllWithField(fs *firestore.Client, field, id string) error {
	// Get refs to all the documents in the collection
	docrefs, err := fs.Collection(WebhookCollection).DocumentRefs(context.Background()).GetAll()
	if err != nil {
		return err
	}

	// For all the docrefs, get their document snapshot, and parse them into webhooks, and invoke them
	for _, docref := range docrefs {
		docsnap, err := docref.Get(context.Background())
		if err != nil {
			return err
		}

		// Parse the document into a webhook
		var webhook Webhook
		err = docsnap.DataTo(&webhook)
		if err != nil {
			return err
		}

		// Skip webhooks with wrong trigger
		if webhook.Trigger != TriggerOnChange {
			continue
		}

		// Skip webhooks with different fields
		if webhook.Field != field {
			continue
		}

		// Skip the webhook that caused the refresh
		if docref.ID == id {
			continue
		}

		// Invoke the webhook, we can ignore any changes that results from this
		_, _, err = webhook.Invoke(fs, docref.ID, true)
		if err != nil {
			return err
		}
	}

	return nil
}
// InvokeAllWithField invokes all the webhooks with the specified field.
InvokeAllWithField invokes all the webhooks with the specified field.
// InvokeAllWithField invokes all the webhooks with the specified field .
func InvokeAllWithField(fs *firestore.Client, field, id string) error {
	docrefs, err := fs.Collection(WebhookCollection).DocumentRefs(context.Background()).GetAll()
	if err != nil {
		return err
	}
	for _, docref := range docrefs {
		docsnap, err := docref.Get(context.Background())
		if err != nil {
			return err
		}
		var webhook Webhook
		err = docsnap.DataTo(&webhook)
		if err != nil {
			return err
		}
		if webhook.Trigger != TriggerOnChange {
			continue
		}
		if webhook.Field != field {
			continue
		}
		if docref.ID == id {
			continue
		}
		_, _, err = webhook.Invoke(fs, docref.ID, true)
		if err != nil {
			return err
		}
	}
	return nil
}
func InvokeAllWithField ( fs * firestore . Client , field , id string ) error { docrefs , err := fs . Collection ( WebhookCollection ) . DocumentRefs ( context . Background ( ) ) . GetAll ( ) if err != nil { return err } for _ , docref := range docrefs { docsnap , err := docref . Get ( context . Background ( ) ) if err != nil { return err } var webhook Webhook err = docsnap . DataTo ( & webhook ) if err != nil { return err } if webhook . Trigger != TriggerOnChange { continue } if webhook . Field != field { continue } if docref . ID == id { continue } _ , _ , err = webhook . Invoke ( fs , docref . ID , true ) if err != nil { return err } } return nil }
InvokeAllWithField invokes all the webhooks with the specified field.
InvokeAllWithField invokes all the webhooks with the specified field .
// Get refs to all the documents in the collection // For all the docrefs, get their document snapshot, and parse them into webhooks, and invoke them // Parse the document into a webhook // Skip webhooks with wrong trigger // Skip webhooks with different fields // Skip the webhook that caused the refresh // Invoke the webhook, we can ignore any changes that results from this