service

package
v0.0.0-...-e341e2a Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package which contains all the services necessary for interacting
with all the collections(tables) in the database.

Each service file should be written in it's own file and should represent only one dbmodels

Index

Constants

View Source
const (
	UsersCollectionName           = "users"
	UserSessionsCollectionName    = "user_sessions"
	EndpointsCollectionName       = "endpoints"
	RequestsHistoryCollectionName = "requests_history"
)

Variables

This section is empty.

Functions

func Connect

func Connect(collectionName string) (*mgo.Session, *mgo.Collection)

All connections should be stateless, so this method always returns a pointer to a new session. After each session is used, it should be closed in order to dump data from memory correctly.

To avoid forgetting to close the session, always write: *defer session.Close()* right after getting it through this method

func CreateEndpoint

func CreateEndpoint(endpoint *dbmodels.Endpoint) (*dbmodels.Endpoint, error)

func CreateRequestHistory

func CreateRequestHistory(requestHistory *dbmodels.RequestHistory) (*dbmodels.RequestHistory, error)

func CreateUser

func CreateUser(user *dbmodels.User) (*dbmodels.User, error)

func CreateUserSession

func CreateUserSession(userSession *dbmodels.UserSession) (*dbmodels.UserSession, error)

func DeleteAllSessionsWithUserId

func DeleteAllSessionsWithUserId(userId bson.ObjectId) error

func DeleteEndpoint

func DeleteEndpoint(endpointId bson.ObjectId) error

func DeleteRequestHistory

func DeleteRequestHistory(requestHistoryId bson.ObjectId) error

func DeleteUser

func DeleteUser(userId bson.ObjectId) error

func DeleteUserSession

func DeleteUserSession(userSessionId bson.ObjectId) error

func GenerateAndInsertUserSession

func GenerateAndInsertUserSession(userId bson.ObjectId) (*dbmodels.UserSession, error)

func GetAllEndpoints

func GetAllEndpoints() ([]dbmodels.Endpoint, error)

func GetAllEndpointsForUser

func GetAllEndpointsForUser(userId bson.ObjectId) ([]dbmodels.Endpoint, error)

func GetAllEndpointsLimited

func GetAllEndpointsLimited(limit int) ([]dbmodels.Endpoint, error)

func GetAllRequestHistorys

func GetAllRequestHistorys() ([]dbmodels.RequestHistory, error)

func GetAllRequestHistorysLimited

func GetAllRequestHistorysLimited(limit int) ([]dbmodels.RequestHistory, error)

func GetAllUserSessions

func GetAllUserSessions() ([]dbmodels.UserSession, error)

func GetAllUserSessionsLimited

func GetAllUserSessionsLimited(limit int) ([]dbmodels.UserSession, error)

func GetAllUsers

func GetAllUsers() ([]dbmodels.User, error)

func GetAllUsersLimited

func GetAllUsersLimited(limit int) ([]dbmodels.User, error)

func GetEndpoint

func GetEndpoint(endpointId bson.ObjectId) (*dbmodels.Endpoint, error)

func GetEndpointByURLPath

func GetEndpointByURLPath(urlPath string) (*dbmodels.Endpoint, error)

func GetEntireRequestHistoryForEndpoint

func GetEntireRequestHistoryForEndpoint(endpointId bson.ObjectId) ([]dbmodels.RequestHistory, error)

func GetRequestHistory

func GetRequestHistory(requestHistoryId bson.ObjectId) (*dbmodels.RequestHistory, error)

func GetUser

func GetUser(userId bson.ObjectId) (*dbmodels.User, error)

func GetUserByUsernameAndPassword

func GetUserByUsernameAndPassword(username, password string) (*dbmodels.User, error)

func GetUserSession

func GetUserSession(userSessionId bson.ObjectId) (*dbmodels.UserSession, error)

func GetUserSessionByToken

func GetUserSessionByToken(token string) (*dbmodels.UserSession, error)

func UpdateEndpoint

func UpdateEndpoint(endpoint *dbmodels.Endpoint) error

func UpdateRequestHistory

func UpdateRequestHistory(requestHistory *dbmodels.RequestHistory) error

func UpdateUser

func UpdateUser(user *dbmodels.User) error

func UpdateUserSession

func UpdateUserSession(userSession *dbmodels.UserSession) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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