github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/sugar/check_exists.go (about)

     1  package sugar
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/scheme/helpers"
     7  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
     8  	"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
     9  )
    10  
    11  func IsTableExists(ctx context.Context, c scheme.Client, absTablePath string) (exists bool, _ error) {
    12  	exists, err := helpers.IsEntryExists(ctx, c, absTablePath, scheme.EntryTable)
    13  	if err != nil {
    14  		return exists, xerrors.WithStackTrace(err)
    15  	}
    16  
    17  	return exists, nil
    18  }
    19  
    20  func IsColumnTableExists(ctx context.Context, c scheme.Client, absTablePath string) (exists bool, _ error) {
    21  	exists, err := helpers.IsEntryExists(ctx, c, absTablePath, scheme.EntryColumnTable)
    22  	if err != nil {
    23  		return exists, xerrors.WithStackTrace(err)
    24  	}
    25  
    26  	return exists, nil
    27  }
    28  
    29  func IsEntryExists(ctx context.Context, c scheme.Client, absPath string, entryTypes ...scheme.EntryType) (
    30  	exists bool, _ error,
    31  ) {
    32  	exists, err := helpers.IsEntryExists(ctx, c, absPath, entryTypes...)
    33  	if err != nil {
    34  		return exists, xerrors.WithStackTrace(err)
    35  	}
    36  
    37  	return exists, nil
    38  }
    39  
    40  func IsDirectoryExists(ctx context.Context, c scheme.Client, absTablePath string) (exists bool, _ error) {
    41  	exists, err := helpers.IsDirectoryExists(ctx, c, absTablePath)
    42  	if err != nil {
    43  		return exists, xerrors.WithStackTrace(err)
    44  	}
    45  
    46  	return exists, nil
    47  }