Documentation
¶
Overview ¶
Package cockroach contains the official implementation of the CockroachDB integration.
Index ¶
- func BlobVByRoleK(site int64, role string, k int64) (v []byte, err error)
- func SiteByDomain(domain string) (*data.Site, error)
- func SitesByIDs(ids []int64) ([]data.Site, error)
- type DB
- func (d *DB) BlobAppendRole(site int64, id int64, role string) (int64, error)
- func (d *DB) BlobByRoleLikeLast(site int64, kPattern string) (*data.Blob, error)
- func (d *DB) BlobDelete(site int64, id int64) (rowsAffected int64, err error)
- func (d *DB) BlobsByRoleInK(site int64, roles []string, k int64) ([]data.Blob, error)
- func (d *DB) BlobsIdIn(site int64, IDs []int64) ([]Blob, error)
- func (d *DB) ContentByAuthor(authorID int64) ([]data.Content, error)
- func (d *DB) ContentByID(id int64) (*data.Content, error)
- func (d *DB) ContentBySiteSlug(siteID int64, slug string) (*data.Content, string, error)
- func (d *DB) ContentCountSlug(siteID int64, slug string) (count int64, err error)
- func (d *DB) ContentInsert(siteID int64, slug string, author int64, pType string, parent int64, ...) (insertID int64, err error)
- func (d *DB) ContentUpdate(contentID int64, vals map[string]interface{}) (int64, error)
- func (d *DB) ContentsByIDs(ids []int64) ([]data.Content, error)
- func (d *DB) ContentsList(siteID int64, cType string, parents []int64, statuses []string, authorID int64, ...) ([]data.Content, error)
- func (d *DB) CountContent(siteID int64, pType string, statuses []string, authorID int64) (countTotal uint16, countParentLevel uint32, err error)
- func (*DB) ErrIsDupKey(e error) bool
- func (d *DB) Init(envVars map[string]string) error
- func (d *DB) InsertSite(domain, name string) (int64, error)
- func (d *DB) OptionByKey(site int64, k string) (*data.Option, error)
- func (d *DB) OptionDelete(site int64, k string) (int64, error)
- func (d *DB) OptionUpdate(site int64, k string, v []byte) (rowsAffected int64, err error)
- func (d *DB) OptionUpdateStr(site int64, k string, v string) (rowsAffected int64, err error)
- func (d *DB) OptionV(site int64, k string) ([]byte, error)
- func (d *DB) OptionsKeyIn(site int64, Ks []string) ([]data.Option, error)
- func (d *DB) OptionsKeyInMapped(site int64, Ks []string) (map[string][]byte, error)
- func (d *DB) OptionsKeyInMappedStr(site int64, Ks []string) (map[string]string, error)
- func (d *DB) OptionsLikeKey(site int64, k string) ([]data.Option, error)
- func (d *DB) OptionsUpdate(site int64, opts map[string]string) (int64, error)
- func (d *DB) Ping() error
- func (d *DB) UserByEmail(email string) (*data.User, error)
- func (d *DB) UserById(id int64) (*data.User, error)
- func (d *DB) UserByUsername(uname string) (*data.User, error)
- func (d *DB) UserCountByUnameEmail(uname, email string) (unameCount int64, emailCount int64, err error)
- func (d *DB) UserInsert(username string, email string, passHash []byte, fname string, lname string) (userID int64, err error)
- func (d *DB) UserMetaById(userID int64) ([]data.UserMeta, error)
- func (d *DB) UserMetaByIdKey(userID int64, k string) (*data.UserMeta, error)
- func (d *DB) UserMetaByIdLikeKey(userID int64, k string) ([]data.UserMeta, error)
- func (d *DB) UserMetaByIdMapped(userID int64) (map[string][]byte, error)
- func (d *DB) UserMetaDelete(userID int64, k string) (int64, error)
- func (d *DB) UserMetaUpdate(userID int64, k string, v []byte) (int64, error)
- func (d *DB) UserMetaV(userID int64, k string) (v []byte, err error)
- func (d *DB) UserMetasUpdate(ums []data.UserMeta) (int64, error)
- func (d *DB) UserPassword(userID int64) (hashedPass []byte, err error)
- func (d *DB) UserSiteInfoByEmail(s *data.Site, email string) (*data.User, error)
- func (d *DB) UserSiteInfoByID(siteID, userID int64) (*data.User, error)
- func (d *DB) UserSiteInfoByUsername(s *data.Site, uname string) (*data.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlobVByRoleK ¶
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 ¶
SiteByDomain retrieves a site by its domain.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB implements the data.DB interface for CockroachDB databases.
func (*DB) BlobAppendRole ¶
BlobAppendRole appends a role to the role column of a Blob and returns the number of rows affected.
func (*DB) BlobByRoleLikeLast ¶
BlobByRoleLikeLast returns the last Blob that is matched to the role column using the LIKE feature, ordered by the record ID.
func (*DB) BlobDelete ¶
BlobDelete deletes a site blob row selected by its ID and returns the number of rows affected.
func (*DB) BlobsByRoleInK ¶
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 ¶
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) ContentByID ¶
ContentByID returns a single Content by its ID.
func (*DB) ContentBySiteSlug ¶
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 ¶
ContentCountSlug returns the number of rows with the given site ID and slug.
func (*DB) ContentInsert ¶
func (*DB) ContentUpdate ¶
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 ¶
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 ¶
ErrIsDupKey says if the error reports a database error indicating that an insert would cause a duplicate key error.
func (*DB) InsertSite ¶
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 ¶
OptionByKey returns a site's option selected by its K.
func (*DB) OptionDelete ¶
OptionDelete deletes a site option selected by its K.
func (*DB) OptionUpdate ¶
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 ¶
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) OptionsKeyIn ¶
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 ¶
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 ¶
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 ¶
OptionsLikeKey returns Option records selected by their K being like k.
func (*DB) OptionsUpdate ¶
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) 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 ¶
UserMetaById returns a all the *UserMeta selected by user ID. This function never returns a sql.ErrNoRows error.
func (*DB) UserMetaByIdKey ¶
UserMetaByIdKey returns a single *UserMeta selected by the user's ID and the K.
func (*DB) UserMetaByIdLikeKey ¶
UserMetaByIdLikeKey returns the *UserMeta rows selected by the user's ID and K values matched by LIKE.
func (*DB) UserMetaByIdMapped ¶
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) UserMetaUpdate ¶
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 ¶
UserMetaV selects just like UserMetaByIdKey but retrieves only the V of the meta datum.
func (*DB) UserMetasUpdate ¶
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) UserSiteInfoByEmail ¶
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 ¶
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 ¶
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.