db

package
v0.0.0-...-ecb7df7 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package db manages database connections and object relational models.

Data models

Vault stores data in three main models:

* Sources describe collections of surveys, nominally from an organization * Surveys describe a collection of questions and their responses * Summaries describe and link to a summary providing information gleaned from one or more surveys.

When it comes to responses to surveys, data is stored in two main models:

* Respondents represent someone who has answered one or more surveys within a source. * Responses represent the list of answers someone has provided to a survey.

Responses are broken down into three main models:

* Questions represent a question that was asked on the survey. They can be simple or complex (lists of answers, structured answers, ...) * Answers represent an answer to a question and are tied to a response. * Touchpoints represent an action that a user took during the survey (such as answering a question, clicking submit, moving to the next page) along with a timestamp.

Vault data is stored in a hierarchy.

Data is stored as data sets called `surveys`. These are grouped together in `sources`, and these sources may belong to a hierarchy of other sources. Additionally, `summaries` of data may belong to these sources.

The hierarchy allows for a descriptive means of storing data from multiple sources. For example, [a][s] runs several surveys, so we might have an `adjspecies` source. Several surveys are grouped together under the Furry Poll heading, which might be named `furrypoll`. These surveys happen every year. Given this, our hierarchy might look like so:

adjspecies (source)
  furrypoll (source)
    2018 (source)
      yearly-summary (summary)
      demographics (survey)
      interests (survey)
      ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct{}

Answer holds a response to a single question.

type DB

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

DB holds connection information and allows querying of the database

func New

func New(options *Options) (*DB, error)

New creates a new DB object and connects to the database specified by the options.

type DataReader

type DataReader interface {
	// Args: slug
	// Returns: model, error
	Source(string, *Source) error
	Survey(string, *Survey) error
	// Args: survey slug, id
	// Returns: model, error
	Response(string, *Response) error
	Respondent(string, *Respondent) error
	// Args: query, order, group, limit, an interface to hold the expected data.
	// Returns: error
	Select(string, string, string, int, *interface{}) error
}

DataReader describes an object which can read data from the database.

type DataWriter

type DataWriter interface {
	WriteSource(Source) error
	WriteSurvey(Survey) error
	WriteSummary(Summary) error
	WriteResponse(Response) error
	WriteRespondent(Respondent) error
	Insert(string) error
	Update(string) error
	Delete(string) error
}

DataWriter describes an object which can write data to the database.

type Options

type Options struct {
	User                    string
	Pass                    string
	DBName                  string
	Host                    string
	Port                    int
	SSLMode                 string
	FallbackApplicationName string
	ConnectionTimeout       int
	SSLCert                 string
	SSLKey                  string
	SSLRootCert             string
}

Options holds all the options allowing connections to a database.

func (*Options) ConnectionString

func (o *Options) ConnectionString() (string, error)

ConnectionString builds the connection string required to connect to a postgres database.

type Question

type Question struct{}

Question holds information about a question in a survey, including type and any sub-questions.

type Respondent

type Respondent struct{}

Respondent represents a user who created a response to one or more surveys.

type Response

type Response struct{}

Response holds all of the answers provided by a respondent to a single survey.

type Source

type Source struct{}

Source holds a data source such as an organization or collection of surveys. It may contain surveys and other sources

type Summary

type Summary struct{}

Summary holds information about a data summary such as an article or visualization.

type Survey

type Survey struct{}

Survey holds a set of responses from a single survey.

type Touchpoint

type Touchpoint struct{}

Touchpoint holds information about an action a user took on a survey.

Jump to

Keyboard shortcuts

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