cardsmgo

package
v0.0.0-...-ee591bf Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CardDoc

type CardDoc struct {
	UID   bson.ObjectId   `bson:"_id"`
	Title string          `bson:"title"`
	Cards []bson.ObjectId `bson:"cards"`
}

type DB

type DB struct {
	*mgo.Session
}

func Open

func Open(dataSourceName string) (*DB, error)

Open returns a DB reference for a data source.

func (*DB) Begin

func (db *DB) Begin() (*Tx, error)

Begin returns the DB instance as MongoDB doesn't support transactions.

type Tx

type Tx struct {
	*mgo.Session
}

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) CreateCard

func (tx *Tx) CreateCard(c *cs.Card) (string, error)

CreateCard creates a new card. Returns the id of the card that was created or an error if the tx fails.

func (*Tx) DeleteCard

func (tx *Tx) DeleteCard(c *cs.Card) (int, error)

DeleteCard deletes a card based on its id. Returns the number of records deleted or an error if the tx fails.

func (*Tx) EmbedCard

func (tx *Tx) EmbedCard(p, c *cs.Card) (int, error)

EmbedCard embeds one card inside another. Returns the number of records amended or an error if the tx fails.

func (*Tx) GetCard

func (tx *Tx) GetCard(c *cs.Card) (*cs.Card, error)

GetCard returns a card based on its identifier. Returns the card or an error if the tx fails.

func (*Tx) RemoveCard

func (tx *Tx) RemoveCard(p, c *cs.Card) (int, error)

RemoveCard embeds one card inside another. Returns the number of records amended or an error if the tx fails.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Jump to

Keyboard shortcuts

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