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: object.go
    path of file: ./repos/moby/vendor/github.com/moby/swarmkit/v2/manager/state/store
    
    the code of the file until where you have to start completion: package store

import (
	memdb "github.com/hashicorp/go-memdb"
	"github.com/moby/swarmkit/v2/api"
)

// ObjectS
    
func RestoreTable(tx Tx, table string, newObjects []api.StoreObject) error {
	checkType := func(by By) error {
		return nil
	}
	var oldObjects []api.StoreObject
	appendResult := func(o api.StoreObject) {
		oldObjects = append(oldObjects, o)
	}

	err := tx.find(table, All, checkType, appendResult)
	if err != nil {
		return nil
	}

	updated := make(map[string]struct{})

	for _, o := range newObjects {
		objectID := o.GetID()
		if existing := tx.lookup(table, indexID, objectID); existing != nil {
			if err := tx.update(table, o); err != nil {
				return err
			}
			updated[objectID] = struct{}{}
		} else {
			if err := tx.create(table, o); err != nil {
				return err
			}
		}
	}
	for _, o := range oldObjects {
		objectID := o.GetID()
		if _, ok := updated[objectID]; !ok {
			if err := tx.delete(table, objectID); err != nil {
				return err
			}
		}
	}
	return nil
}