lifecycle

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lifecycle

type Lifecycle struct {
	Engine engine.Engine
}

func (*Lifecycle) Connect

func (c *Lifecycle) Connect() error

Connect connects to the Prisma query engine. Required to call before accessing data. It is recommended to immediately defer calling Disconnect.

Example:

if err := client.Prisma.Connect(); err != nil {
  handle(err)
}

defer func() {
  if err := client.Prisma.Disconnect(); err != nil {
    panic(fmt.Errorf("could not disconnect: %w", err))
  }
}()

func (*Lifecycle) Disconnect

func (c *Lifecycle) Disconnect() error

Disconnect disconnects from the Prisma query engine. This is usually invoked on kill signals in long running applications (like webservers), or when no database access is needed anymore (like after executing a CLI command).

Should be usually invoked directly after calling client.Prisma.Connect(), for example as follows:

// after client.Prisma.Connect()

defer func() {
  if err := client.Prisma.Disconnect(); err != nil {
    panic(fmt.Errorf("could not disconnect: %w", err))
  }
}()

Jump to

Keyboard shortcuts

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