Documentation
¶
Index ¶
- Constants
- func ConditionToParameterized(tableName string, c *orm.Condition) (gorqlite.ParameterizedStatement, error)
- func DBRecordToInsertParameterized(d *orm.DBRecord) gorqlite.ParameterizedStatement
- func DBRecordsToInsertParameterized(d orm.DBRecords) []gorqlite.ParameterizedStatement
- func FromManyParameterizedSQL(p []orm.ParametereizedSQL) []gorqlite.ParameterizedStatement
- func FromOneParameterizedSQL(p orm.ParametereizedSQL) gorqlite.ParameterizedStatement
- func WriteResultToBasicSQLResult(res gorqlite.WriteResult) orm.BasicSQLResult
- func WriteResultsToBasicSQLResults(res []gorqlite.WriteResult) []orm.BasicSQLResult
- type RQLiteDB
- func (db RQLiteDB) ExecManySQL(sql []string) ([]orm.BasicSQLResult, error)
- func (db RQLiteDB) ExecManySQLParameterized(p []orm.ParametereizedSQL) ([]orm.BasicSQLResult, error)
- func (db RQLiteDB) ExecOneSQL(sql string) orm.BasicSQLResult
- func (db RQLiteDB) ExecOneSQLParameterized(p orm.ParametereizedSQL) orm.BasicSQLResult
- func (db RQLiteDB) GetSchema(hideSQL, hideSureSQL bool) []orm.SchemaStruct
- func (db RQLiteDB) InsertManyDBRecords(records []orm.DBRecord, queue bool) ([]orm.BasicSQLResult, error)
- func (db RQLiteDB) InsertManyDBRecordsSameTable(records []orm.DBRecord, queue bool) ([]orm.BasicSQLResult, error)
- func (db RQLiteDB) InsertManyTableStructs(objs []orm.TableStruct, queue bool) ([]orm.BasicSQLResult, error)
- func (db RQLiteDB) InsertOneDBRecord(record orm.DBRecord, queue bool) orm.BasicSQLResult
- func (db RQLiteDB) InsertOneTableStruct(obj orm.TableStruct, queue bool) orm.BasicSQLResult
- func (db RQLiteDB) IsConnected() bool
- func (db RQLiteDB) Leader() (string, error)
- func (db RQLiteDB) Peers() ([]string, error)
- func (db RQLiteDB) SelectMany(tableName string) (orm.DBRecords, error)
- func (db RQLiteDB) SelectManyWithCondition(tableName string, condition *orm.Condition) ([]orm.DBRecord, error)
- func (db RQLiteDB) SelectOne(tableName string) (orm.DBRecord, error)
- func (db RQLiteDB) SelectOneWithCondition(tableName string, condition *orm.Condition) (orm.DBRecord, error)
- func (db RQLiteDB) Status() (orm.NodeStatusStruct, error)
- type RqliteConfig
Constants ¶
const ( PREFIX_SURESQL_TABLE = "_" PREFIX_SQLITE_TABLE = "sqlite_" )
Variables ¶
This section is empty.
Functions ¶
func DBRecordToInsertParameterized ¶
func DBRecordToInsertParameterized(d *orm.DBRecord) gorqlite.ParameterizedStatement
Convert DBRecord to ParameterizedStatement
func DBRecordsToInsertParameterized ¶
func DBRecordsToInsertParameterized(d orm.DBRecords) []gorqlite.ParameterizedStatement
Convert DBRecords to []ParameterizedStatement
func FromManyParameterizedSQL ¶
func FromManyParameterizedSQL(p []orm.ParametereizedSQL) []gorqlite.ParameterizedStatement
convert from many simpleORM ParameterizedSQL to gorqlite.ParameterizedStatement
func FromOneParameterizedSQL ¶
func FromOneParameterizedSQL(p orm.ParametereizedSQL) gorqlite.ParameterizedStatement
convert from 1 simpleORM ParameterizedSQL to gorqlite.ParameterizedStatement
func WriteResultToBasicSQLResult ¶
func WriteResultToBasicSQLResult(res gorqlite.WriteResult) orm.BasicSQLResult
func WriteResultsToBasicSQLResults ¶
func WriteResultsToBasicSQLResults(res []gorqlite.WriteResult) []orm.BasicSQLResult
Types ¶
type RQLiteDB ¶
type RQLiteDB struct {
Config RqliteConfig
// contains filtered or unexported fields
}
func NewDatabase ¶
func NewDatabase(config RqliteConfig) (RQLiteDB, error)
This is to "connect" to the DB. Basically we use gorqlite to do so. If using credential, then it will use that as well and return error if it's not matched
func (RQLiteDB) ExecManySQL ¶
func (db RQLiteDB) ExecManySQL(sql []string) ([]orm.BasicSQLResult, error)
Execute many raw sql statement, can be anything. Query, Update, Insert, etc
func (RQLiteDB) ExecManySQLParameterized ¶
func (db RQLiteDB) ExecManySQLParameterized(p []orm.ParametereizedSQL) ([]orm.BasicSQLResult, error)
Execute many raw sql statement, can be anything. Query, Update, Insert, etc
func (RQLiteDB) ExecOneSQL ¶
func (db RQLiteDB) ExecOneSQL(sql string) orm.BasicSQLResult
Execute 1 raw sql statement, can be anything. Query, Update, Insert, etc Combine the error from write function to result.Err
func (RQLiteDB) ExecOneSQLParameterized ¶
func (db RQLiteDB) ExecOneSQLParameterized(p orm.ParametereizedSQL) orm.BasicSQLResult
Execute 1 raw sql statement, can be anything. Query, Update, Insert, etc
func (RQLiteDB) GetSchema ¶
func (db RQLiteDB) GetSchema(hideSQL, hideSureSQL bool) []orm.SchemaStruct
Get all the schema for the database, basically returns all the table that exists!
func (RQLiteDB) InsertManyDBRecords ¶
func (db RQLiteDB) InsertManyDBRecords(records []orm.DBRecord, queue bool) ([]orm.BasicSQLResult, error)
Insert many records, that can be of different tables, that means we have to execute per statement When queue=true the query result is not used, it will return only 1 result with LastInsertID = sequence number and RowsAffected as len(records)
func (RQLiteDB) InsertManyDBRecordsSameTable ¶
func (db RQLiteDB) InsertManyDBRecordsSameTable(records []orm.DBRecord, queue bool) ([]orm.BasicSQLResult, error)
Insert array of records which we know for sure it's the same table. This should be faster than using InsertManyDBRecords if bulk inserting 1 table with many records When queue=true the query result is not used, instead the first array of Result{LastInsertID : is the sequence number }
func (RQLiteDB) InsertManyTableStructs ¶
func (db RQLiteDB) InsertManyTableStructs(objs []orm.TableStruct, queue bool) ([]orm.BasicSQLResult, error)
Insert many table structs (in array) but use the DB records.
func (RQLiteDB) InsertOneDBRecord ¶
Insert DBRecord into the DB. The table name is stored in DBRecord if queue == true, this means we are using the queueFunction and there is no error (most of the time) because queueFunction is returning the API status from rqlite, if it succeed it's not the sql command but the API is succeed. if false then we can get the error right away from the command
func (RQLiteDB) InsertOneTableStruct ¶
func (db RQLiteDB) InsertOneTableStruct(obj orm.TableStruct, queue bool) orm.BasicSQLResult
NOTE: with inserting struct, be careful on the ID field. Usually we have
ID in a table with autoincrement, this struct when converted to map if the struct.ID is not set, it will be converted to the map[ID]=0 So the insert will fail! Use this accordingly!! Saver to use InsertOneDBRecord() function because we can NOT set the map[ID] to any value, then the DB will use the default or autoincrement value!
Insert TableStruct to DB
func (RQLiteDB) IsConnected ¶
func (RQLiteDB) SelectManyWithCondition ¶
func (db RQLiteDB) SelectManyWithCondition(tableName string, condition *orm.Condition) ([]orm.DBRecord, error)
Select many rows (returned as []DBRecords) with condition.
func (RQLiteDB) SelectOne ¶
NOTE: This is almost not used because very rare cases where we need to select from table without - conditions but only return 1 Select only 1 row, if multiple rows returned, it only takes the first one
func (RQLiteDB) SelectOneWithCondition ¶
func (db RQLiteDB) SelectOneWithCondition(tableName string, condition *orm.Condition) (orm.DBRecord, error)
Select 1 row from a table passed in tableName with condition (read condition struct for usage) Will return only 1 row of type DBRecord and error if any.