Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPerson ¶
func AddPerson(p Person) (*mongo.InsertOneResult, error)
AddPerson adds a record of Person in people collection
func CollectionRef ¶
func CollectionRef(db, col string) *mongo.Collection
CollectionRef returns a pointer to the respective collection in database
func ConnectDatabase ¶
func ConnectDatabase() (*mongo.Client, context.CancelFunc)
ConnectDatabase connects to the mongo database and returns a Client
func FormatErrorMesssage ¶
FormatErrorMesssage formats a server error message
Types ¶
type Person ¶
type Person struct { ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"` FirstName string `json:"firstname,omitempty" bson:"firstname,omitempty"` LastName string `json:"lastname,omitempty" bson:"lastname,omitempty"` }
Person type for to represent a person
func FindPersonByID ¶
FindPersonByID finds the person using id and returns it
type ServerError ¶
type ServerError struct {
Message string `json:"message"`
}
ServerError helps handle error responses
Click to show internal directories.
Click to hide internal directories.