postgres_backend

package module
v0.0.0-...-b838c0c Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2013 License: MIT Imports: 12 Imported by: 0

README

PostgreSQL Backend for straumur

Build Status

Databackend for straumur


package main

import (
	"github.com/straumur/straumur"
	"github.com/straumur/postgres_backend"
)

func main() {

	connString := "dbname=activityfeed host=localhost sslmode=disable"
	
	d, err := postgres_backend.NewPostgresDataSource(connString)
	if err != nil {
		panic(err)
	}	
	h := eventhub.NewHub("Application", d)
	h.Run()

}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MigrationTuples = make(map[string]string)

Functions

This section is empty.

Types

type ByAge

type ByAge struct{ Migrations }

Sort by date

func (ByAge) Less

func (s ByAge) Less(i, j int) bool

type Migration

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

func (Migration) String

func (m Migration) String() string

type Migrations

type Migrations []Migration

func (Migrations) FilterDates

func (m Migrations) FilterDates(t []time.Time) (nm Migrations)

Returns a new Migration array with the provided dates filtered out

func (Migrations) Len

func (m Migrations) Len() int

func (Migrations) Swap

func (m Migrations) Swap(i, j int)

type PostgresDataSource

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

func NewPostgresDataSource

func NewPostgresDataSource(connection string) (*PostgresDataSource, error)

Creates a new PostgresDataSource

func (*PostgresDataSource) AggregateType

func (p *PostgresDataSource) AggregateType(q straumur.Query, s string) (map[string]int, error)

func (*PostgresDataSource) GetById

func (p *PostgresDataSource) GetById(id int) (*straumur.Event, error)

Gets an event by id

func (*PostgresDataSource) Query

func (*PostgresDataSource) Save

func (p *PostgresDataSource) Save(e *straumur.Event) (err error)

Saves or updates an event

type StringSlice

type StringSlice []string

func (*StringSlice) Scan

func (s *StringSlice) Scan(src interface{}) error

Implements sql.Scanner for the String slice type Scanners take the database value (in this case as a byte slice) and sets the value of the type. Here we cast to a string and do a regexp based parse

type TransactionFunc

type TransactionFunc func(*sql.Tx) error

Callback for a managed transaction

Example:

	err := p.wrapTransaction(func(tx *sql.Tx) error {
	    rows, err := tx.Query(query, args...)
     if err != nil {
        return err
     }
}

Jump to

Keyboard shortcuts

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