Documentation ¶
Index ¶
- type MongoDBUser
- func (e *MongoDBUser) GetAll() (users []dataFormat.User, length int, err error)
- func (e *MongoDBUser) GetByEmail(mail string) (user dataFormat.User, err error)
- func (e *MongoDBUser) Install() (err error)
- func (e *MongoDBUser) MailExists(mail string) (found bool, err error)
- func (e *MongoDBUser) Set(id string, admin int, name, nickName, email, password string) (err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoDBUser ¶
type MongoDBUser struct { MongoDB.MongoDB ClientUser *mongo.Collection }
func New ¶
func New() (referenceInicialized *MongoDBUser, err error)
func (*MongoDBUser) GetAll ¶
func (e *MongoDBUser) GetAll() (users []dataFormat.User, length int, err error)
func (*MongoDBUser) GetByEmail ¶
func (e *MongoDBUser) GetByEmail(mail string) (user dataFormat.User, err error)
Example ¶
var err error var user dataFormat.User var userAsByte []byte var sqlUser = MongoDBUser{} err = sqlUser.Connect(constants.KMongoDBConnectionString) if err != nil { log.Fatalf("sqlUser.Connect().error: %v", err.Error()) } err = sqlUser.Install() if err != nil { log.Fatalf("sqlUser.Install().error: %v", err.Error()) } var found bool found, err = sqlUser.MailExists("helmut.kemper@gmail.com") if err != nil { log.Fatalf("sqlUser.MailExists().error: %v", err.Error()) } if found == false { log.Fatal("sqlUser.MailExists().found: false") } user, err = sqlUser.GetByEmail("helmut.kemper@gmail.com") if err != nil { log.Fatalf("sqlUser.GetMainMenu().error: %v", err.Error()) } userAsByte, err = json.Marshal(&user) if err != nil { log.Fatalf("json.Marshal().error: %v", err.Error()) } fmt.Printf("%s", userAsByte)
Output: {"id":"24867707-3a21-4368-8058-3d7b1ddb8c06","manuId":"5996b891-9d3c-4038-af37-cb07f5f0f72d","admin":1,"name":"Helmut Kemper","nickname":"Kemper","mail":"helmut.kemper@gmail.com"}
func (*MongoDBUser) Install ¶
func (e *MongoDBUser) Install() (err error)
func (*MongoDBUser) MailExists ¶
func (e *MongoDBUser) MailExists(mail string) (found bool, err error)
Click to show internal directories.
Click to hide internal directories.