Example #1
0
File: db.go Project: keep94/vsafe
func (s Store) AddEntry(
	t db.Transaction, entry *vsafe.Entry) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return sqlite_db.AddRow(
			conn, &rawEntry{}, entry, &entry.Id, kSQLAddEntry)
	})
}
Example #2
0
File: db.go Project: keep94/vsafe
func (s Store) Users(
	t db.Transaction, consumer functional.Consumer) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return sqlite_db.ReadMultiple(
			conn,
			&rawUser{},
			consumer,
			kSQLUsers)
	})
}
Example #3
0
File: db.go Project: keep94/vsafe
func (s Store) EntriesByOwner(
	t db.Transaction, owner int64, consumer functional.Consumer) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return sqlite_db.ReadMultiple(
			conn,
			&rawEntry{},
			consumer,
			kSQLEntryByOwner,
			owner)
	})
}
Example #4
0
File: db.go Project: keep94/vsafe
func (s Store) UserByName(
	t db.Transaction, name string, user *vsafe.User) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return sqlite_db.ReadSingle(
			conn,
			&rawUser{},
			vsafedb.ErrNoSuchId,
			user,
			kSQLUserByName,
			name)
	})
}
Example #5
0
File: db.go Project: keep94/vsafe
func (s Store) EntryByIdWithEtag(
	t db.Transaction, id int64, entry *vsafe.EntryWithEtag) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return sqlite_db.ReadSingle(
			conn,
			&rawEntry{},
			vsafedb.ErrNoSuchId,
			entry,
			kSQLEntryById,
			id)
	})
}
Example #6
0
File: db.go Project: keep94/vsafe
func (s Store) RemoveUser(
	t db.Transaction, name string) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return conn.Exec(kSQLRemoveUser, name)
	})
}
Example #7
0
File: db.go Project: keep94/vsafe
func (s Store) UpdateUser(
	t db.Transaction, user *vsafe.User) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return sqlite_db.UpdateRow(conn, &rawUser{}, user, kSQLUpdateUser)
	})
}
Example #8
0
File: db.go Project: keep94/vsafe
func (s Store) AddUser(
	t db.Transaction, user *vsafe.User) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return sqlite_db.AddRow(conn, &rawUser{}, user, &user.Id, kSQLAddUser)
	})
}
Example #9
0
File: db.go Project: keep94/vsafe
func (s Store) RemoveEntry(t db.Transaction, id, owner int64) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return conn.Exec(kSQLRemoveEntry, id, owner)
	})
}
Example #10
0
File: db.go Project: keep94/vsafe
func (s Store) UpdateEntry(t db.Transaction, entry *vsafe.Entry) error {
	return sqlite_db.ToDoer(s.db, t).Do(func(conn *sqlite.Conn) error {
		return sqlite_db.UpdateRow(conn, &rawEntry{}, entry, kSQLUpdateEntry)
	})
}