示例#1
0
文件: models.go 项目: Hipo/gotcha
func (a Application) CreateApplication() error {
	err := mongo.Insert(a)
	if err != nil {
		return err
	}
	return nil
}
示例#2
0
文件: models.go 项目: Hipo/gotcha
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
}
示例#3
0
文件: models.go 项目: Hipo/gotcha
func (u UrlRecord) CreateUrlRecord() error {

	u.DateCreated = time.Now()
	err := mongo.Insert(u)
	if err != nil {
		panic(err)
	}
	return nil
}
示例#4
0
文件: models.go 项目: Hipo/gotcha
func (u Url) CreateUrl() error {
	u.Id = bson.NewObjectId()
	mongo.Insert(u)
	return nil
}