File: changes.go

package info (click to toggle)
golang-github-hashicorp-go-memdb 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates, bullseye, sid, trixie
  • size: 296 kB
  • sloc: makefile: 5
file content (34 lines) | stat: -rw-r--r-- 996 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package memdb

// Changes describes a set of mutations to memDB tables performed during a
// transaction.
type Changes []Change

// Change describes a mutation to an object in a table.
type Change struct {
	Table  string
	Before interface{}
	After  interface{}

	// primaryKey stores the raw key value from the primary index so that we can
	// de-duplicate multiple updates of the same object in the same transaction
	// but we don't expose this implementation detail to the consumer.
	primaryKey []byte
}

// Created returns true if the mutation describes a new object being inserted.
func (m *Change) Created() bool {
	return m.Before == nil && m.After != nil
}

// Updated returns true if the mutation describes an existing object being
// updated.
func (m *Change) Updated() bool {
	return m.Before != nil && m.After != nil
}

// Deleted returns true if the mutation describes an existing object being
// deleted.
func (m *Change) Deleted() bool {
	return m.Before != nil && m.After == nil
}