// Save saves the AuthUserUserPermission to the database.
433737
func (auup *AuthUserUserPermission) Save(db XODB) error {
	if auup.Exists() {
		return auup.Update(db)
	}

	return auup.Insert(db)
}
1145705
func (dct *DjangoContentType) Save(db XODB) error {
	if dct.Exists() {
		return dct.Update(db)
	}

	return dct.Insert(db)
}
580229
func (b LeveldbAuthBackend) SaveUser(user UserData) error {
	b.users[user.Username] = user
	err := b.save()
	return err
}
1197325
func (auup *AuthUserUserPermission) Update(db XODB) error {
	var err error

	// if doesn't exist, bail
	if !auup._exists {
		return errors.New("update failed: does not exist")
	}

	// if deleted, bail
	if auup._deleted {
		return errors.New("update failed: marked for deletion")
	}

	// sql query
	const sqlstr = `UPDATE django.auth_user_user_permissions SET ` +
		`user_id = ?, permission_id = ?` +
		` WHERE id = ?`

	// run query
	XOLog(sqlstr, auup.UserID, auup.PermissionID, auup.ID)
	_, err = db.Exec(sqlstr, auup.UserID, auup.PermissionID, auup.ID)
	return err
}
178714
func (r *Repo) Save(ctx context.Context, entity eh.Entity) error {
	r.SaveCalled = true
	if r.SaveErr != nil {
		return r.SaveErr
	}
	r.Entity = entity
	return nil
}
911728
func (auup *AuthUserUserPermission) AuthUser(db XODB) (*AuthUser, error) {
	return AuthUserByID(db, auup.UserID)
}
1337287
func (m *GormResourceRepository) Save(ctx context.Context, resource *Resource) error {
	defer goa.MeasureSince([]string{"goa", "db", "resource", "save"}, time.Now())

	err := m.db.Save(resource).Error

	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"resource_id": resource.ResourceID,
			"err":         err,
		}, "unable to update the resource")
		return errs.WithStack(err)
	}

	log.Debug(ctx, map[string]interface{}{
		"resource_id": resource.ResourceID,
	}, "Resource saved!")

	return nil
}
853324
func (p *Secring) Save() error {
	buf, err := proto.Marshal(p.data)
	if err != nil {
		return err
	}
	if err := os.MkdirAll(filepath.Dir(p.File), 0700); err != nil {
		return err
	}
	return ioutil.WriteFile(p.File, buf, 0600)
}
1006949
func (player *Player) Save() error {
	var err error
	if db.DB.NewRecord(player) {
		err = db.DB.Create(player).Error
	} else {
		err = db.DB.Save(player).Error
	}
	return err
}
847387
func (m *Manager) saveAuthorizationRequest(ar *authorizationRequest) (err error) {
	// TODO: Validation!

	err = m.getAuthorizationRequestCollection().Insert(ar)

	return
}
45027
func (w *wrapper) Save() error {
	w.mut.Lock()
	defer w.mut.Unlock()

	fd, err := osutil.CreateAtomic(w.path)
	if err != nil {
		l.Debugln("CreateAtomic:", err)
		return err
	}

	if err := w.cfg.WriteXML(fd); err != nil {
		l.Debugln("WriteXML:", err)
		fd.Close()
		return err
	}

	if err := fd.Close(); err != nil {
		l.Debugln("Close:", err)
		return err
	}

	events.Default.Log(events.ConfigSaved, w.cfg)
	return nil
}
1306601
func (target *MySQLTarget) Save(eventData event.Event) error {
	return target.send(eventData)
}
386613
func (m *AggregateStore) Save(ctx context.Context, aggregate eh.Aggregate) error {
	if m.Err != nil {
		return m.Err
	}
	m.Context = ctx
	m.Aggregates[aggregate.EntityID()] = aggregate
	return nil
}
257950
func Save(collectionName string, doc interface{}) error {
	connection := shared.Connection()
	if connection == nil {
		log.Println("MongoConn", connection)
		return errors.New("No connection to database server")
	}
	err := Insert(collectionName, doc)
	if err == nil {
		return nil
	}
	return Update(collectionName, doc)
}
75969
func Save(args *RequestArgs) error {
	user := args.User
	appName := args.AppName
	org := args.Organization

	stats_query := utils.M{
		"user":     user,
		"app_name": appName,
		"org":      org,
	}

	save_doc := utils.M{
		"user":      user,
		"app_name":  appName,
		"org":       org,
		"timestamp": utils.EpochNow(),
	}

	return db.Conn.Upsert(db.StatsCollection, stats_query, save_doc)
}
1085193
func (s *Session) Save(w http.ResponseWriter) error {
	return s.store.Save(w, s)
}
1315655
func (m *Msg) Save(db *sqlx.DB) error {
	var pluginName string
	if m.Plugin != nil {
		pluginName = m.Plugin.Config.Name
	}
	q := `INSERT INTO messages
	      (userid, sentence, plugin, route, abotsent, needstraining, flexid,
		flexidtype, trained)
	      VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id`
	row := db.QueryRowx(q, m.User.ID, m.Sentence, pluginName, m.Route,
		m.AbotSent, m.NeedsTraining, m.User.FlexID, m.User.FlexIDType,
		m.Trained)
	if err := row.Scan(&m.ID); err != nil {
		return err
	}
	return nil
}