You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: update_array_operators.go
    path of file: ./repos/FerretDB/internal/handler/common
    
    the code of the file until where you have to start completion: // Copyright 2021 FerretDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package common

import (
	"errors"
	"fmt"

	"github.com/FerretDB/FerretDB/internal/handler/handlererrors"
	"github.com/FerretDB/FerretDB/internal/handler/handlerparams"
	"github.com/FerretDB/FerretDB/internal/types"
	"github.com/FerretDB/FerretDB/internal/util/iterator"
	"github.com/FerretDB/FerretDB/internal/util/lazyerrors"
	"github.com/FerretDB/FerretDB/internal/util/must"
)

// processPopArrayUpdateExpression changes document according to $pop operator.
// If the document was changed it returns true.
func processPopArrayUpdateExpression(doc *types.Document, update *types.Document) (bool, error) {
	var changed bool

	iter := update.Iterator()
	defer iter.Close()

	for {
		key, popValueRaw, err := iter.Next()
		if err != nil {
			if errors.Is(err, iterator.ErrIteratorDone) {
				break
			}

			return false, lazyerrors.Error(err)
		}

		popValue, err := handlerparams.GetWholeNumberParam(popValueRaw)
		if err != nil {
			return false, handlererrors.NewWriteErrorMsg(
				handlererrors.ErrFailedToParse,
				fmt.Sprintf(`Expected a number in: %s: "%v"`, key, popValueRaw),
			)
		}

		if p
    
func processPushArrayUpdateExpression(doc *types.Document, update *types.Document) (bool, error) {
	var changed bool

	iter := update.Iterator()
	defer iter.Close()

	for {
		key, pushValueRaw, err := iter.Next()
		if err != nil {
			if errors.Is(err, iterator.ErrIteratorDone) {
				break
			}

			return false, lazyerrors.Error(err)
		}

		var each *types.Array

		if pushValue, ok := pushValueRaw.(*types.Document); ok {
			if pushValue.Has("$each") {
				eachRaw := must.NotFail(pushValue.Get("$each"))

				each, ok = eachRaw.(*types.Array)
				if !ok {
					return false, handlererrors.NewWriteErrorMsg(
						handlererrors.ErrBadValue,
						fmt.Sprintf(
							"The argument to $each in $push must be an array but it was of type: %s",
							handlerparams.AliasFromType(eachRaw),
						),
					)
				}
			}
		}

		path, err := types.NewPathFromString(key)
		if err != nil {
			return false, lazyerrors.Error(err)
		}

		// If the path does not exist, create a new array and set it.
		if !doc.HasByPath(path) {
			changed = true

			if err = doc.SetByPath(path, types.MakeArray(1)); err != nil {
				return false, handlererrors.NewWriteErrorMsg(
					handlererrors.ErrUnsuitableValueType,
					err.Error(),
				)
			}
		}

		val, err := doc.GetByPath(path)
		if err != nil {
			return false, err
		}

		array, ok := val.(*types.Array)
		if !ok {
			return false, handlererrors.NewWriteErrorMsg(
				handlererrors.ErrBadValue,
				fmt.Sprintf(
					"The field '%s' must be an array but is of type '%s' in document {_id: %s}",
					key, handlerparams.AliasFromType(val), types.FormatAnyValue(must.NotFail(doc.Get("_id"))),
				),
			)
		}

		if each == nil {
			each = types.MakeArray(1)
			each.Append(pushValueRaw)
		}

		for i := 0; i < each.Len(); i++ {
			array.Append(must.NotFail(each.Get(i)))

			changed = true
		}

		if err = doc.SetByPath(path, array); err != nil {
			return false, lazyerrors.Error(err)
		}
	}

	return changed, nil
}