db

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionFollow n1qlQuery = iota
	ActionLike
	ActionSubmit
	ActionUnfollow
	ActionUnlike
	AnoUserActivities
	AnoUserComments
	AnoUserFollowers
	AnoUserFollowing
	AnoUserLikes
	AnoUserSubmissions
	BehaviorReport
	CountAnoUserActivities
	CountStrings
	CountStringsWithSubstring
	CountUserActivities
	DeleteActivity
	FileComments
	FileStrings
	FileStringsWithSubstring
	FileSummary
	GetAllDocType
	MetaUI
	UserActivities
	UserComments
	UserFollowers
	UserFollowing
	UserLikes
	UserSubmissions
)

Variables

View Source
var (
	// ErrDocumentNotFound is returned when the doc does not exist in the DB.
	ErrDocumentNotFound = errors.New("document not found")
	ErrSubDocNotFound   = gocb.ErrPathNotFound
)

Functions

This section is empty.

Types

type DB

type DB struct {
	Bucket     *gocb.Bucket
	Cluster    *gocb.Cluster
	Collection *gocb.Collection
	N1QLQuery  map[n1qlQuery]string
}

DB represents the database connection.

func Open

func Open(server, username, password, bucketName string) (*DB, error)

Open opens a connection to the database.

func (*DB) Count

func (db *DB) Count(ctx context.Context, statement string,
	args map[string]interface{}, val *int) error

Count retrieves the total number of documents.

func (*DB) Create

func (db *DB) Create(ctx context.Context, key string, val interface{}) error

Create saves a new document into the collection.

func (*DB) Delete

func (db *DB) Delete(ctx context.Context, key string) error

Delete removes a document from the collection.

func (*DB) Exists added in v0.4.0

func (db *DB) Exists(ctx context.Context, key string, docExists *bool) error

Exists checks weather a document exists in the DB.

func (*DB) Get

func (db *DB) Get(ctx context.Context, key string, model interface{}) error

Get retrieves the document using its key.

func (*DB) Lookup

func (db *DB) Lookup(ctx context.Context, key string, paths []string,
	val interface{}) error

Lookup query the document for certain path(s); these path(s) are then returned.

func (*DB) Patch

func (db *DB) Patch(ctx context.Context, key string, path string,
	val interface{}) error

Patch performs a sub document in the collection. Sub documents operations may be quicker and more network-efficient than full-document operations.

func (*DB) PrepareQueries

func (db *DB) PrepareQueries(filePath, bucketName string) error

PrepareQueries iterate over the list of n1ql files and load them to memory.

func (*DB) Query

func (db *DB) Query(ctx context.Context, statement string,
	args map[string]interface{}, val *interface{}) error

Query executes a N1QL query.

func (*DB) Update

func (db *DB) Update(ctx context.Context, key string, val interface{}) error

Update updates a document in the collection.

Jump to

Keyboard shortcuts

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