susumu.yata
null+****@clear*****
Wed Jun 24 16:00:40 JST 2015
susumu.yata 2015-06-24 16:00:40 +0900 (Wed, 24 Jun 2015) New Revision: 045ed43b058666046d2b6afec82e81454cfba570 https://github.com/groonga/grngo/commit/045ed43b058666046d2b6afec82e81454cfba570 Message: Add SetValue and GetValue to DB and Table for convenience. Modified files: grngo.go Modified: grngo.go (+36 -0) =================================================================== --- grngo.go 2015-06-24 15:45:31 +0900 (b6a5cc7) +++ grngo.go 2015-06-24 16:00:40 +0900 (a60e9ea) @@ -577,6 +577,24 @@ func (db *DB) FindColumn(tableName, columnName string) (*Column, error) { return table.FindColumn(columnName) } +// SetValue assigns a value. +func (db *DB) SetValue(tableName, columnName string, id uint32, value interface{}) error { + table, err := db.FindTable(tableName) + if err != nil { + return err + } + return table.SetValue(columnName, id, value) +} + +// GetValue gets a value. +func (db *DB) GetValue(tableName, columnName string, id uint32) (interface{}, error) { + table, err := db.FindTable(tableName) + if err != nil { + return nil, err + } + return table.GetValue(columnName, id) +} + // -- Table -- // Table is associated with a Groonga table. @@ -739,6 +757,24 @@ func (table *Table) InsertRow(key interface{}) (inserted bool, id uint32, err er } } +// SetValue assigns a value. +func (table *Table) SetValue(columnName string, id uint32, value interface{}) error { + column, err := table.FindColumn(columnName) + if err != nil { + return err + } + return column.SetValue(id, value) +} + +// GetValue gets a value. +func (table *Table) GetValue(columnName string, id uint32) (interface{}, error) { + column, err := table.FindColumn(columnName) + if err != nil { + return nil, err + } + return column.GetValue(id) +} + // CreateColumn creates a Groonga column and returns a new Column associated // with it. // -------------- next part -------------- HTML����������������������������...Download