Beispiel #1
0
func (a Application) CreateApplication() error {
	err := mongo.Insert(a)
	if err != nil {
		return err
	}
	return nil
}
Beispiel #2
0
func (u User) CreateUser() error {
	hashedPassword, err := bcrypt.GenerateFromPassword([]byte(u.Password), bcrypt.DefaultCost)
	u.Password = string(hashedPassword)
	u.Token = randToken()
	u.Id = bson.NewObjectId()
	err = mongo.Insert(u)
	fmt.Println(err)
	return err
}
Beispiel #3
0
func (u UrlRecord) CreateUrlRecord() error {

	u.DateCreated = time.Now()
	err := mongo.Insert(u)
	if err != nil {
		panic(err)
	}
	return nil
}
Beispiel #4
0
func (u Url) CreateUrl() error {
	u.Id = bson.NewObjectId()
	mongo.Insert(u)
	return nil
}