persistence

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2023 The Simila Authors

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.

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.

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.

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.

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.

Index

Constants

View Source
const (
	PqUniqueViolationError = pq.ErrorCode("23505")
)

Variables

This section is empty.

Functions

func NewMigration

func NewMigration(driverName, dataSourceName string) *migration

Types

type Db

type Db interface {
	// NewModelTx creates new ModelTx object
	NewModelTx() ModelTx
	// NewTx creates Tx object
	NewTx() Tx
}

db interface exposes

func NewDb

func NewDb(driverName, dataSourceName string) Db

NewDb creates new db object

type ModelTx

type ModelTx interface {
	Tx

	// CreateTestRecord this is a test call, REMOVE it when everything works
	CreateTestRecord(t TestRecord) (string, error)
}

ModelTx provides a transaction with some methods for accessing to the Model objects

type QueryResult

type QueryResult[T any] struct {
	Items []T
	Total int64
}

type SqlTestSuite

type SqlTestSuite struct {
	Dir string
	suite.Suite
	// contains filtered or unexported fields
}

SqlTestSuite struct used to wrap all related database connection stuff into one suite

func (*SqlTestSuite) AfterTest

func (s *SqlTestSuite) AfterTest(suiteName, testName string)

func (*SqlTestSuite) BeforeTest

func (s *SqlTestSuite) BeforeTest(suiteName, testName string)

func (*SqlTestSuite) GetDb

func (s *SqlTestSuite) GetDb() Db

func (*SqlTestSuite) SetupSuite

func (s *SqlTestSuite) SetupSuite()

func (*SqlTestSuite) TearDownSuite

func (s *SqlTestSuite) TearDownSuite()

type TestRecord

type TestRecord struct {
	ID string `db:"id"`
}

type Tx

type Tx interface {
	// MustBegin starts the transaction
	MustBegin()
	// MustBeginSerializable starts new transaction with Serializable isolation level
	MustBeginSerializable(ctx context.Context)
	// Commit commits the changes made within the transaction
	Commit() error
	// Rollback rolls the transaction back
	Rollback() error
	// ExecScript allows to execute the sql statements from the file provided
	ExecScript(sqlScript string) error
}

Tx interface describes an abstract DB transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL