entity

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2018, Square, Inc.

Index

Constants

View Source
const (
	VALIDATE_ON_CREATE byte = iota
	VALIDATE_ON_UPDATE
	VALIDATE_ON_DELETE
)

Variables

This section is empty.

Functions

func Filter added in v0.11.0

func Filter(q query.Query) bson.M

Filter translates a query.Query into a mongo-driver filter paramter.

func IsDupeKeyError added in v0.11.0

func IsDupeKeyError(err error) error

func NewStore

func NewStore(entities map[string]*mongo.Collection, cdcStore cdc.Store) store

NewStore creates a Store.

func NewValidator

func NewValidator(entityTypes []string) validator

Types

type DbError

type DbError struct {
	Err      error
	Type     string
	EntityId string
}

func (DbError) Error

func (e DbError) Error() string

type Store

type Store interface {
	WithContext(context.Context) Store

	ReadEntities(string, query.Query, etre.QueryFilter) ([]etre.Entity, error)

	CreateEntities(WriteOp, []etre.Entity) ([]string, error)

	UpdateEntities(WriteOp, query.Query, etre.Entity) ([]etre.Entity, error)

	DeleteEntities(WriteOp, query.Query) ([]etre.Entity, error)

	DeleteLabel(WriteOp, string) (etre.Entity, error)
}

Store interface has methods needed to do CRUD operations on entities.

type ValidationError

type ValidationError struct {
	Err  error
	Type string
}

func (ValidationError) Error

func (e ValidationError) Error() string

type Validator

type Validator interface {
	EntityType(string) error
	Entities([]etre.Entity, byte) error
	WriteOp(WriteOp) error
	DeleteLabel(string) error
}

type WriteOp

type WriteOp struct {
	Caller     string // required (auth.Caller.Name)
	EntityType string // required
	EntityId   string // optional

	// Delete ops do not support set ops like insert and update because no
	// entities are sent by the client on delete. However, the caller can do
	// DELETE /entity/node?setOp=foo&setId=bar&setSize=2 and the controller
	// will pass along the set op values. This could (but not currently) also
	// be used to impose/inject a set op on a write op that doesn't specify
	// a set op.
	SetOp   string // optional
	SetId   string // optional
	SetSize int    // optional
}

WriteOp represents common metadata for insert, update, and delete Store methods.

Jump to

Keyboard shortcuts

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