cockroach

package
v0.0.0-...-1d33cbc Latest Latest
Warning

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

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

Documentation

Overview

Package cockroach contains the official implementation of the CockroachDB integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlobVByRoleK

func BlobVByRoleK(site int64, role string, k int64) (v []byte, err error)

BlobVByRoleK returns the v of a single Blob selected by both the role and the k. This function wil return a sql.ErrNoRows error if no matching row is found.

func SiteByDomain

func SiteByDomain(domain string) (*data.Site, error)

SiteByDomain retrieves a site by its domain.

func SitesByIDs

func SitesByIDs(ids []int64) ([]data.Site, error)

SitesByIDs retrieves sites by their ID.

Types

type DB

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

DB implements the data.DB interface for CockroachDB databases.

func (*DB) BlobAppendRole

func (d *DB) BlobAppendRole(site int64, id int64, role string) (int64, error)

BlobAppendRole appends a role to the role column of a Blob and returns the number of rows affected.

func (*DB) BlobByRoleLikeLast

func (d *DB) BlobByRoleLikeLast(site int64, kPattern string) (*data.Blob, error)

BlobByRoleLikeLast returns the last Blob that is matched to the role column using the LIKE feature, ordered by the record ID.

func (*DB) BlobDelete

func (d *DB) BlobDelete(site int64, id int64) (rowsAffected int64, err error)

BlobDelete deletes a site blob row selected by its ID and returns the number of rows affected.

func (*DB) BlobsByRoleInK

func (d *DB) BlobsByRoleInK(site int64, roles []string, k int64) ([]data.Blob, error)

BlobsByRoleInK selects blobs where the role matches a role in the given list and the K equals the given k. If not matching Blobs are found, an empty slice is returned but no error.

func (*DB) BlobsIdIn

func (d *DB) BlobsIdIn(site int64, IDs []int64) ([]Blob, error)

BlobsForTree retrieves the data blobs necessary to build a page tree. The IDs list contains the IDs of the tree elements, the static settings of dynamic elements, and the published rows of the dynamic elements.

func (*DB) ContentByAuthor

func (d *DB) ContentByAuthor(authorID int64) ([]data.Content, error)

func (*DB) ContentByID

func (d *DB) ContentByID(id int64) (*data.Content, error)

ContentByID returns a single Content by its ID.

func (*DB) ContentBySiteSlug

func (d *DB) ContentBySiteSlug(siteID int64, slug string) (*data.Content, string, error)

ContentBySiteSlug returns a single Content by the site ID and slug given; the string returned is the parent slug, which is blank if the content has no parent.

func (*DB) ContentCountSlug

func (d *DB) ContentCountSlug(siteID int64, slug string) (count int64, err error)

ContentCountSlug returns the number of rows with the given site ID and slug.

func (*DB) ContentInsert

func (d *DB) ContentInsert(siteID int64, slug string, author int64, pType string, parent int64, title string) (insertID int64, err error)

func (*DB) ContentUpdate

func (d *DB) ContentUpdate(contentID int64, vals map[string]interface{}) (int64, error)

ContentUpdate updates a single content record, the values passed in as column-name -> value pairs. The number returned is the number of rows affected by the update.

func (*DB) ContentsByIDs

func (d *DB) ContentsByIDs(ids []int64) ([]data.Content, error)

ContentsByIDs returns the Content rows selected by their ID.

func (*DB) ContentsList

func (d *DB) ContentsList(siteID int64, cType string, parents []int64, statuses []string, authorID int64, offset uint64) ([]data.Content, error)

ContentsList retrieves the specified Content items. The parent argument should be either nil to indicate that the parent column should not be considered in the query, or a list of the parent IDs to which the returned items should belong. The value of offset may never be negative, which is why its type is uint64.

func (*DB) CountContent

func (d *DB) CountContent(siteID int64, pType string, statuses []string, authorID int64) (countTotal uint16, countParentLevel uint32, err error)

CountContent says how many content pages/posts there are with the given parameters and how many such have no parent. Optionally give a non-zero authorID to also filter by author. The given statuses should not have any punctuation at all (should be already sanitized).

func (*DB) ErrIsDupKey

func (*DB) ErrIsDupKey(e error) bool

ErrIsDupKey says if the error reports a database error indicating that an insert would cause a duplicate key error.

func (*DB) Init

func (d *DB) Init(envVars map[string]string) error

func (*DB) InsertSite

func (d *DB) InsertSite(domain, name string) (int64, error)

InsertSite inserts a record into the sites table and create all needed tables for the site. The int64 returned is the ID of the new site (the inserted row). The domain passed in must have already been validated as a real domain name.

func (*DB) OptionByKey

func (d *DB) OptionByKey(site int64, k string) (*data.Option, error)

OptionByKey returns a site's option selected by its K.

func (*DB) OptionDelete

func (d *DB) OptionDelete(site int64, k string) (int64, error)

OptionDelete deletes a site option selected by its K.

func (*DB) OptionUpdate

func (d *DB) OptionUpdate(site int64, k string, v []byte) (rowsAffected int64, err error)

OptionUpdate updates an Option or creates a new record in the database if necessary.

The primary key is set by both the site ID and the value of K.

func (*DB) OptionUpdateStr

func (d *DB) OptionUpdateStr(site int64, k string, v string) (rowsAffected int64, err error)

OptionUpdateStr updates an Option or creates a new record in the database if necessary).

The primary key is set by both the site ID and the value of K.

func (*DB) OptionV

func (d *DB) OptionV(site int64, k string) ([]byte, error)

OptionV returns the V of a site's option selected by key.

func (*DB) OptionsKeyIn

func (d *DB) OptionsKeyIn(site int64, Ks []string) ([]data.Option, error)

OptionsKeyIn returns the options selected by site ID and the K IN list. The strings in the Ks list must be valid UTF-8 strings.

func (*DB) OptionsKeyInMapped

func (d *DB) OptionsKeyInMapped(site int64, Ks []string) (map[string][]byte, error)

OptionsKeyInMapped returns a map of the K-V pairs of a site's options selected by the Ks IN list. This function always returns a non-nil map, though the map may be empty. An error is not returned if there are no records retrieved.

func (*DB) OptionsKeyInMappedStr

func (d *DB) OptionsKeyInMappedStr(site int64, Ks []string) (map[string]string, error)

OptionsKeyInMappedStr returns a map of the K-V pairs of a site's options selected by the Ks In list, with the V values converted to strings. This function always returns a non-nil map, though the map may be empty. An error is not returned if there are no records retrieved.

func (*DB) OptionsLikeKey

func (d *DB) OptionsLikeKey(site int64, k string) ([]data.Option, error)

OptionsLikeKey returns Option records selected by their K being like k.

func (*DB) OptionsUpdate

func (d *DB) OptionsUpdate(site int64, opts map[string]string) (int64, error)

OptionsUpdate updates Option records or creates new records in the database if necessary. The strings passed in as keys in the map must be valid UTF-8 strings. Returned is the number of rows affected.

The primary key is set by both the site ID and the value of K in each element.

func (*DB) Ping

func (d *DB) Ping() error

func (*DB) UserByEmail

func (d *DB) UserByEmail(email string) (*data.User, error)

func (*DB) UserById

func (d *DB) UserById(id int64) (*data.User, error)

func (*DB) UserByUsername

func (d *DB) UserByUsername(uname string) (*data.User, error)

func (*DB) UserCountByUnameEmail

func (d *DB) UserCountByUnameEmail(uname, email string) (unameCount int64, emailCount int64, err error)

UserCountByUnameEmail says how many users there are with the given username and how many there are with the given email address.

func (*DB) UserInsert

func (d *DB) UserInsert(username string, email string, passHash []byte, fname string, lname string) (userID int64, err error)

UserInsert creates a new user record with the given details in u and the password.

func (*DB) UserMetaById

func (d *DB) UserMetaById(userID int64) ([]data.UserMeta, error)

UserMetaById returns a all the *UserMeta selected by user ID. This function never returns a sql.ErrNoRows error.

func (*DB) UserMetaByIdKey

func (d *DB) UserMetaByIdKey(userID int64, k string) (*data.UserMeta, error)

UserMetaByIdKey returns a single *UserMeta selected by the user's ID and the K.

func (*DB) UserMetaByIdLikeKey

func (d *DB) UserMetaByIdLikeKey(userID int64, k string) ([]data.UserMeta, error)

UserMetaByIdLikeKey returns the *UserMeta rows selected by the user's ID and K values matched by LIKE.

func (*DB) UserMetaByIdMapped

func (d *DB) UserMetaByIdMapped(userID int64) (map[string][]byte, error)

UserMetaByIdMapped returns a map of the K => V pairs of the user meta selected by user ID. This function always returns a non-nil map, though the map may be empty if an error occurs.

func (*DB) UserMetaDelete

func (d *DB) UserMetaDelete(userID int64, k string) (int64, error)

func (*DB) UserMetaUpdate

func (d *DB) UserMetaUpdate(userID int64, k string, v []byte) (int64, error)

UserMetaUpdate updates a UserMeta (creating a new record in the database if necessary) and returns the number of rows affected. The primary key is set by both the user ID and k. The Updated time cannot be set directly but is automatically updated by the database.

func (*DB) UserMetaV

func (d *DB) UserMetaV(userID int64, k string) (v []byte, err error)

UserMetaV selects just like UserMetaByIdKey but retrieves only the V of the meta datum.

func (*DB) UserMetasUpdate

func (d *DB) UserMetasUpdate(ums []data.UserMeta) (int64, error)

UserMetasUpdate updates UserMeta records, creating new records in the database if necessary and returns the number of rows affected.

The primary key is set by both the user ID and the value of K in each element. The Updated time cannot be set directly but is automatically updated by the database.

func (*DB) UserPassword

func (d *DB) UserPassword(userID int64) (hashedPass []byte, err error)

func (*DB) UserSiteInfoByEmail

func (d *DB) UserSiteInfoByEmail(s *data.Site, email string) (*data.User, error)

UserSiteInfoByEmail gets the basic info for a user along with the user's role for the site. This function always returns a non-nil *User (which has just zero values for all fields if an error occurs). The error will be sql.ErrNoRows if a user is not found.

func (*DB) UserSiteInfoByID

func (d *DB) UserSiteInfoByID(siteID, userID int64) (*data.User, error)

UserSiteInfoByID gets the basic info for a user along with the user's role for the site. This function always returns a non-nil *User (which has just zero values for all fields if an error occurs). The error will be sql.ErrNoRows if a user is not found.

func (*DB) UserSiteInfoByUsername

func (d *DB) UserSiteInfoByUsername(s *data.Site, uname string) (*data.User, error)

UserSiteInfoByUsername gets the basic info for a user along with the user's role for the site. This function always returns a non-nil *User (which has just zero values for all fields if an error occurs). The error will be sql.ErrNoRows if a user is not found.

Jump to

Keyboard shortcuts

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