cb

package
v0.0.0-...-c042da3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Overview

Package cb implements the DataStore interface for CouchBase

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cb

type Cb struct {
	Conn *gocb.Bucket
}

Cb implements a DataSource interface to CouchBase

func (*Cb) Browse

func (ds *Cb) Browse(bucket string, where string, offset int64, limit int64, sort string, order string) ([]interface{}, error)

Browse fills out a slice of Foods, Nutrients or NutrientData items, returns gocb error

func (*Cb) Bulk

func (ds *Cb) Bulk(items *[]fdc.NutrientData) error

Bulk inserts a list of Nutrient Data items

func (*Cb) BulkInsert

func (ds *Cb) BulkInsert(items []gocb.BulkOp) error

BulkInsert uses gocb library to insert a list of items defined in BulkOp struct

func (*Cb) CloseDs

func (ds *Cb) CloseDs()

CloseDs is a wrapper for the connection close func

func (*Cb) ConnectDs

func (ds *Cb) ConnectDs(cs fdc.Config) error

ConnectDs connects to a datastore, e.g. Couchbase, MongoDb, etc.

func (*Cb) Counts

func (ds *Cb) Counts(bucket string, doctype string, c *[]interface{}) error

Counts returns document counts for a specified document type

func (Cb) FoodExists

func (ds Cb) FoodExists(id string) bool

FoodExists uses Couchbase subdoc API to determine if a key exists or not

func (Cb) Get

func (ds Cb) Get(q string, f interface{}) error

Get finds data for a single food

func (*Cb) GetDictionary

func (ds *Cb) GetDictionary(bucket string, doctype string, offset int64, limit int64) ([]interface{}, error)

GetDictionary returns dictionary documents, e.g. food groups, nutrients, derivations, etc.

func (*Cb) NutrientReport

func (ds *Cb) NutrientReport(bucket string, nr fdc.NutrientReportRequest, nutrients *[]interface{}) error

NutrientReport Runs a NutrientReportRequest

func (Cb) Query

func (ds Cb) Query(q string, f *[]interface{}) error

Query performs an arbitrary but well-formed query

func (*Cb) Remove

func (ds *Cb) Remove(id string) error

Remove removes a document in the datastore

func (*Cb) Search

func (ds *Cb) Search(sr fdc.SearchRequest, foods *[]interface{}) (int, error)

Search performs a search query, fills out a Foods slice and returns count, error

func (*Cb) Update

func (ds *Cb) Update(id string, r interface{}) error

Update updates an existing document in the datastore using Upsert

Jump to

Keyboard shortcuts

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