db

package
v0.0.0-...-491560f Latest Latest
Warning

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

Go to latest
Published: May 25, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Db database
)

Functions

func Connect

func Connect(url string) error

func Disconnect

func Disconnect()

func GetTripByID

func GetTripByID(userID string)

GetTripByID returns a single trip by id

func InsertTrip

func InsertTrip(trip *Trip) error

InsertTrip adds a trip

func InsertUser

func InsertUser(user User) error

InsertUser adds a user to the system

func TripCollectionToJSON

func TripCollectionToJSON(in []Trip) ([]byte, error)

TripCollectionToJSON passes every object through bson before converting to json. To serialize inline properly. TODO: replace inline with something else

func UpdateTrip

func UpdateTrip(trip *Trip) error

UpdateTrip updates the trip

func UpdateUser

func UpdateUser(user User) error

UpdateUser updates a user in the system

Types

type Trip

type Trip struct {
	ID     bson.ObjectId `bson:"_id,omitempty"`    // ID of the trip
	UserID bson.ObjectId `bson:"userId,omitempty"` // UserId of the trip owner
	Data   bson.M        `bson:",inline"`          // extra Data about the trip
}

Trip represents a single trip

func GetAllTrips

func GetAllTrips(userID string) (results []Trip, err *errors.Error)

GetAllTrips returns all trips by the user

type User

type User struct {
	ID    bson.ObjectId `bson:"_id,omitempty"`
	Name  string        `bson:"name"`
	Email string        `bson:"email"`

	AccessToken  string `bson:"access_token"`
	RefreshToken string `bson:"refresh_token"`
}

User represents a logged in user

func FindAndUpdateOrCreateUser

func FindAndUpdateOrCreateUser(userDetails google.GoogleUser) (User, error)

FindAndUpdateOrCreateUser performs an upsert to the user

func FindUserByEmail

func FindUserByEmail(email string) (User, error)

FindUserByEmail finds a user by e-mail

func FindUserByID

func FindUserByID(ID string) (User, error)

FindUserByID finds a user by it's ID

Jump to

Keyboard shortcuts

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