Documentation
¶
Overview ¶
Package bindings provides minimal GopherJS bindings around the SQL.js (https://github.com/lovasoa/sql.js)
Index ¶
- type Database
- func (d *Database) Close() (e error)
- func (d *Database) Exec(query string) (r []Result, e error)
- func (d *Database) Export() io.Reader
- func (d *Database) GetRowsModified() int64
- func (d *Database) Prepare(query string) (s *Statement, e error)
- func (d *Database) PrepareNamedParams(query string, params map[string]interface{}) (s *Statement, e error)
- func (d *Database) PrepareParams(query string, params []interface{}) (s *Statement, e error)
- func (d *Database) Run(query string) (e error)
- func (d *Database) RunParams(query string, params []interface{}) (e error)
- type Result
- type Statement
- func (s *Statement) Bind(params []interface{}) (e error)
- func (s *Statement) BindNamed(params map[string]interface{}) (e error)
- func (s *Statement) Free() bool
- func (s *Statement) Freemem()
- func (s *Statement) Get() (r []interface{}, e error)
- func (s *Statement) GetAsMap() (m map[string]interface{}, e error)
- func (s *Statement) GetAsMapNamedParams(params map[string]interface{}) (m map[string]interface{}, e error)
- func (s *Statement) GetAsMapParams(params []interface{}) (m map[string]interface{}, e error)
- func (s *Statement) GetColumnNames() (c []string, e error)
- func (s *Statement) GetNamedParams(params map[string]interface{}) (r []interface{}, e error)
- func (s *Statement) GetParams(params []interface{}) (r []interface{}, e error)
- func (s *Statement) Reset()
- func (s *Statement) Run() (e error)
- func (s *Statement) RunNamedParams(params map[string]interface{}) (e error)
- func (s *Statement) RunParams(params []interface{}) (e error)
- func (s *Statement) Step() (ok bool, e error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
func New ¶
func New() *Database
New returns a new database by creating a new one in memory
See http://lovasoa.github.io/sql.js/documentation/class/Database.html#constructor-dynamic
func OpenReader ¶
OpenReader opens an existing database, referenced by the passed io.Reader
See http://lovasoa.github.io/sql.js/documentation/class/Database.html#constructor-dynamic
func (*Database) Close ¶
Close the database and all associated prepared statements.
See http://kripken.github.io/sql.js/documentation/class/Database.html#close-dynamic
func (*Database) Exec ¶
Exec will execute an SQL query, and return the result.
This is a wrapper around Database.Prepare(), Statement.Step(), Statement.Get(), and Statement.Free().
The result is an array of Result elements. There are as many result elements as the number of statements in your sql string (statements are separated by a semicolon).
See http://kripken.github.io/sql.js/documentation/class/Database.html#exec-dynamic
func (*Database) Export ¶
Export the contents of the database to an io.Reader
See http://kripken.github.io/sql.js/documentation/class/Database.html#export-dynamic
func (*Database) GetRowsModified ¶
GetRowsModified returns the number of rows modified, inserted or deleted by the most recently completed INSERT, UPDATE or DELETE statement. Executing any other type of SQL statement does not modify the value returned by this function.
See http://kripken.github.io/sql.js/documentation/class/Database.html#getRowsModified-dynamic
func (*Database) Prepare ¶
Prepare an SQL statement
See http://kripken.github.io/sql.js/documentation/class/Database.html#prepare-dynamic
func (*Database) PrepareNamedParams ¶
func (d *Database) PrepareNamedParams(query string, params map[string]interface{}) (s *Statement, e error)
Prepare an SQL statement, with named parameters
See http://kripken.github.io/sql.js/documentation/class/Database.html#prepare-dynamic
func (*Database) PrepareParams ¶
Prepare an SQL statement, with array of parameters
See http://kripken.github.io/sql.js/documentation/class/Database.html#prepare-dynamic
func (*Database) Run ¶
Run will execute one or more SQL queries (separated by ';'), ignoring the rows it returns
See http://kripken.github.io/sql.js/documentation/class/Database.html#run-dynamic
type Statement ¶
func (*Statement) Bind ¶
Bind values to parameters, after having reset the statement.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#bind-dynamic
func (*Statement) BindNamed ¶
BindNamed binds values to named parameters, after having reset the statement.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#bind-dynamic
func (*Statement) Free ¶
Free frees any memory used by the statement.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#free-dynamic
func (*Statement) Freemem ¶
func (s *Statement) Freemem()
Freemem frees memory allocated during paramater binding.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#freemem-dynamic
func (*Statement) Get ¶
Get one row of results of a statement. Step() must have been called first.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#get-dynamic
func (*Statement) GetAsMap ¶
GetAsMap will get one row of result as a javascript object, associating column names with their value in the current row.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#getAsObject-dynamic
func (*Statement) GetAsMapNamedParams ¶
func (s *Statement) GetAsMapNamedParams(params map[string]interface{}) (m map[string]interface{}, e error)
GetAsMapNamedParams will get one row of result as a javascript object, associating column names with their value in the current row, after binding the parameters and executing the statement
See http://kripken.github.io/sql.js/documentation/class/Statement.html#getAsObject-dynamic
func (*Statement) GetAsMapParams ¶
GetAsMapParams will get one row of result as a javascript object, associating column names with their value in the current row, after binding the parameters and executing the statement
See http://kripken.github.io/sql.js/documentation/class/Statement.html#getAsObject-dynamic
func (*Statement) GetColumnNames ¶
GetColumnNames list of column names of a row of result of a statement.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#getColumnNames-dynamic
func (*Statement) GetNamedParams ¶
GetNamedParams will get one row of results of a statement after binding the parameters and executing the statement.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#get-dynamic
func (*Statement) GetParams ¶
GetParams will get one row of results of a statement after binding the parameters and executing the statement.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#get-dynamic
func (*Statement) Reset ¶
func (s *Statement) Reset()
Reset a statement, so that it's parameters can be bound to new values. It also clears all previous bindings, freeing the memory used by bound parameters.
See http://kripken.github.io/sql.js/documentation/class/Statement.html#reset-dynamic
func (*Statement) Run ¶
Run is shorthand for Bind() + Step() + Reset(). Bind the values, execute the statement, ignoring the rows it returns, and resets it
See http://kripken.github.io/sql.js/documentation/class/Statement.html#run-dynamic
func (*Statement) RunNamedParams ¶
RunNamedParams is shorthand for Bind() + Step() + Reset(). Bind the values, execute the statement, ignoring the rows it returns, and resets it
See http://kripken.github.io/sql.js/documentation/class/Statement.html#run-dynamic
func (*Statement) RunParams ¶
RunParams is shorthand for Bind() + Step() + Reset(). Bind the values, execute the statement, ignoring the rows it returns, and resets it
See http://kripken.github.io/sql.js/documentation/class/Statement.html#run-dynamic