recordutil

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveDeltaRecord

func DeriveDeltaRecord(dst, base, delta *skydb.Record)

DeriveDeltaRecord derive fields in delta which is either new or different from base, and write them in dst.

It is the caller's reponsibility to ensure that base and delta identify the same record

func DoQueryEager

func DoQueryEager(ctx context.Context, db skydb.Database, eagersIDs map[string][]skydb.RecordID, accessControlOptions *skydb.AccessControlOptions) map[string]map[string]*skydb.Record

func EagerIDs

func EagerIDs(db skydb.Database, records []skydb.Record, query skydb.Query) map[string][]skydb.RecordID

func ExtendRecordSchema

func ExtendRecordSchema(ctx context.Context, db skydb.Database, records []*skydb.Record) (bool, error)

func MakeAssetsComplete

func MakeAssetsComplete(db skydb.Database, conn skydb.Conn, records []skydb.Record) error

func QueryResultInfo

func QueryResultInfo(db skydb.Database, query *skydb.Query, accessControlOptions *skydb.AccessControlOptions, results *skydb.Rows) (map[string]interface{}, error)

func RecordDeleteHandler

func RecordDeleteHandler(req *RecordModifyRequest, resp *RecordModifyResponse) skyerr.Error

func RecordSaveHandler

func RecordSaveHandler(req *RecordModifyRequest, resp *RecordModifyResponse) skyerr.Error

RecordSaveHandler iterate the record to perform the following: 1. Query the db for original record 2. Execute before save hooks with original record and new record 3. Clean up some transport only data (sequence for example) away from record 4. Populate meta data and save the record (like updated_at/by) 5. Execute after save hooks with original record and new record

Types

type QueryResultFilter

type QueryResultFilter struct {
	Database           skydb.Database
	Query              skydb.Query
	EagerRecords       map[string]map[string]*skydb.Record
	RecordResultFilter RecordResultFilter
}

func (*QueryResultFilter) JSONResult

func (f *QueryResultFilter) JSONResult(record *skydb.Record) *skyconv.JSONRecord

type RecordFetcher

type RecordFetcher struct {
	// contains filtered or unexported fields
}

func NewRecordFetcher

func NewRecordFetcher(ctx context.Context, db skydb.Database, conn skydb.Conn, withMasterKey bool) RecordFetcher

NewRecordFetcher provide a convenient FetchOrCreateRecord method

func (RecordFetcher) FetchOrCreateRecord

func (f RecordFetcher) FetchOrCreateRecord(recordID skydb.RecordID, authInfo *skydb.AuthInfo, bypassAccess bool) (record skydb.Record, created bool, err skyerr.Error)

func (RecordFetcher) FetchRecord

func (f RecordFetcher) FetchRecord(recordID skydb.RecordID, authInfo *skydb.AuthInfo, accessLevel skydb.RecordACLLevel) (record *skydb.Record, err skyerr.Error)

type RecordModifyRequest

type RecordModifyRequest struct {
	Db            skydb.Database
	Conn          skydb.Conn
	AssetStore    asset.Store
	HookRegistry  *hook.Registry
	Atomic        bool
	WithMasterKey bool
	Context       context.Context
	AuthInfo      *skydb.AuthInfo
	ModifyAt      time.Time

	// Save only
	RecordsToSave []*skydb.Record

	// Delete Only
	RecordIDsToDelete []skydb.RecordID

	// Bypass ACL even if it is restricted in _record_creation
	BypassCreationAccess bool
}

type RecordModifyResponse

type RecordModifyResponse struct {
	ErrMap           map[skydb.RecordID]skyerr.Error
	SavedRecords     []*skydb.Record
	DeletedRecordIDs []skydb.RecordID
}

type RecordResultFilter

type RecordResultFilter struct {
	AssetStore          asset.Store
	FieldACL            skydb.FieldACL
	AuthInfo            *skydb.AuthInfo
	BypassAccessControl bool
}

RecordResultFilter is for processing Record into results.

  1. Apply field-based acl, remove fields that are not accessible to the provided authInfo
  2. Inject asset
  3. Return JSONRecord that is a copy of passed in Record that is ready to be serialized

func NewRecordResultFilter

func NewRecordResultFilter(conn skydb.Conn, assetStore asset.Store, authInfo *skydb.AuthInfo, bypassAccessControl bool) (RecordResultFilter, error)

NewRecordResultFilter return a RecordResultFilter.

func (*RecordResultFilter) JSONResult

func (f *RecordResultFilter) JSONResult(record *skydb.Record) *skyconv.JSONRecord

Jump to

Keyboard shortcuts

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