summary refs log blame commit diff stats
path: root/search/word.go
blob: c83c31862ffc3bb82b59d19f4a647132c6b61e23 (plain) (tree)
1
2
3
4
5
6

              
                                          

                                                                       
                                                                   








                                                                               
                                               




                       
package search

import "tildegit.org/andinus/grus/storage"

// Word will search for unjumbled words in database, given sorted word.
func Word(sorted string, db *storage.DB) (word string, err error) {
	db.Mu.RLock()
	defer db.Mu.RUnlock()

	stmt, err := db.Conn.Prepare("SELECT word FROM words WHERE sorted = ?")
	if err != nil {
		return
	}
	defer stmt.Close()

	err = stmt.QueryRow(sorted).Scan(&word)
	if err != nil {
		return
	}
	return
}