mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-10-29 17:12:22 +00:00
user []map insead of []bson
This commit is contained in:
@@ -717,7 +717,7 @@ func (dbobj MySQLDB) CleanupRecord(t Tbl, keyName string, keyValue string, bdel
|
||||
}
|
||||
|
||||
// GetExpiring get records that are expiring
|
||||
func (dbobj MySQLDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]bson.M, error) {
|
||||
func (dbobj MySQLDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
now := int32(time.Now().Unix())
|
||||
q := fmt.Sprintf("select * from %s WHERE endtime>0 AND endtime<%d AND %s=?",
|
||||
@@ -729,7 +729,7 @@ func (dbobj MySQLDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]bson
|
||||
}
|
||||
|
||||
// GetUniqueList returns a unique list of values from specific column in database
|
||||
func (dbobj MySQLDB) GetUniqueList(t Tbl, keyName string) ([]bson.M, error) {
|
||||
func (dbobj MySQLDB) GetUniqueList(t Tbl, keyName string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
keyName = dbobj.escapeName(keyName)
|
||||
q := "select distinct " + keyName + " from " + table + " ORDER BY " + keyName
|
||||
@@ -739,7 +739,7 @@ func (dbobj MySQLDB) GetUniqueList(t Tbl, keyName string) ([]bson.M, error) {
|
||||
}
|
||||
|
||||
// GetList is used to return list of rows. It can be used to return values using pager.
|
||||
func (dbobj MySQLDB) GetList0(t Tbl, start int32, limit int32, orderField string) ([]bson.M, error) {
|
||||
func (dbobj MySQLDB) GetList0(t Tbl, start int32, limit int32, orderField string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
if limit > 100 {
|
||||
limit = 100
|
||||
@@ -761,7 +761,7 @@ func (dbobj MySQLDB) GetList0(t Tbl, start int32, limit int32, orderField string
|
||||
}
|
||||
|
||||
// GetList is used to return list of rows. It can be used to return values using pager.
|
||||
func (dbobj MySQLDB) GetList(t Tbl, keyName string, keyValue string, start int32, limit int32, orderField string) ([]bson.M, error) {
|
||||
func (dbobj MySQLDB) GetList(t Tbl, keyName string, keyValue string, start int32, limit int32, orderField string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
if limit > 100 {
|
||||
limit = 100
|
||||
@@ -782,7 +782,7 @@ func (dbobj MySQLDB) GetList(t Tbl, keyName string, keyValue string, start int32
|
||||
return dbobj.getListDo(q, values)
|
||||
}
|
||||
|
||||
func (dbobj MySQLDB) getListDo(q string, values []interface{}) ([]bson.M, error) {
|
||||
func (dbobj MySQLDB) getListDo(q string, values []interface{}) ([]map[string]interface{}, error) {
|
||||
tx, err := dbobj.db.Begin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -804,11 +804,11 @@ func (dbobj MySQLDB) getListDo(q string, values []interface{}) ([]bson.M, error)
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var results []bson.M
|
||||
var results []map[string]interface{}
|
||||
//pointers := make([]interface{}, len(columnNames))
|
||||
//rows.Next()
|
||||
for rows.Next() {
|
||||
recBson := bson.M{}
|
||||
recBson := make(map[string]interface{})
|
||||
columnPointers := make([]interface{}, len(columnNames))
|
||||
columns := make([]interface{}, len(columnNames))
|
||||
for idx := range columns {
|
||||
|
||||
@@ -715,7 +715,7 @@ func (dbobj PGSQLDB) CleanupRecord(t Tbl, keyName string, keyValue string, bdel
|
||||
}
|
||||
|
||||
// GetExpiring get records that are expiring
|
||||
func (dbobj PGSQLDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]bson.M, error) {
|
||||
func (dbobj PGSQLDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
now := int32(time.Now().Unix())
|
||||
q := fmt.Sprintf("select * from %s WHERE endtime>0 AND endtime<%d AND %s=$1",
|
||||
@@ -727,7 +727,7 @@ func (dbobj PGSQLDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]bson
|
||||
}
|
||||
|
||||
// GetUniqueList returns a unique list of values from specific column in database
|
||||
func (dbobj PGSQLDB) GetUniqueList(t Tbl, keyName string) ([]bson.M, error) {
|
||||
func (dbobj PGSQLDB) GetUniqueList(t Tbl, keyName string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
keyName = dbobj.escapeName(keyName)
|
||||
q := "select distinct " + keyName + " from " + table + " ORDER BY " + keyName
|
||||
@@ -737,7 +737,7 @@ func (dbobj PGSQLDB) GetUniqueList(t Tbl, keyName string) ([]bson.M, error) {
|
||||
}
|
||||
|
||||
// GetList is used to return list of rows. It can be used to return values using pager.
|
||||
func (dbobj PGSQLDB) GetList0(t Tbl, start int32, limit int32, orderField string) ([]bson.M, error) {
|
||||
func (dbobj PGSQLDB) GetList0(t Tbl, start int32, limit int32, orderField string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
if limit > 100 {
|
||||
limit = 100
|
||||
@@ -759,7 +759,7 @@ func (dbobj PGSQLDB) GetList0(t Tbl, start int32, limit int32, orderField string
|
||||
}
|
||||
|
||||
// GetList is used to return list of rows. It can be used to return values using pager.
|
||||
func (dbobj PGSQLDB) GetList(t Tbl, keyName string, keyValue string, start int32, limit int32, orderField string) ([]bson.M, error) {
|
||||
func (dbobj PGSQLDB) GetList(t Tbl, keyName string, keyValue string, start int32, limit int32, orderField string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
if limit > 100 {
|
||||
limit = 100
|
||||
@@ -780,7 +780,7 @@ func (dbobj PGSQLDB) GetList(t Tbl, keyName string, keyValue string, start int32
|
||||
return dbobj.getListDo(q, values)
|
||||
}
|
||||
|
||||
func (dbobj PGSQLDB) getListDo(q string, values []interface{}) ([]bson.M, error) {
|
||||
func (dbobj PGSQLDB) getListDo(q string, values []interface{}) ([]map[string]interface{}, error) {
|
||||
tx, err := dbobj.db.Begin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -789,7 +789,7 @@ func (dbobj PGSQLDB) getListDo(q string, values []interface{}) ([]bson.M, error)
|
||||
return dbobj.getListDoRaw(tx, q, values)
|
||||
}
|
||||
|
||||
func (dbobj PGSQLDB) getListDoRaw(tx *sql.Tx, q string, values []interface{}) ([]bson.M, error) {
|
||||
func (dbobj PGSQLDB) getListDoRaw(tx *sql.Tx, q string, values []interface{}) ([]map[string]interface{}, error) {
|
||||
rows, err := tx.Query(q, values...)
|
||||
if err == sql.ErrNoRows {
|
||||
fmt.Println("nothing found")
|
||||
@@ -807,11 +807,11 @@ func (dbobj PGSQLDB) getListDoRaw(tx *sql.Tx, q string, values []interface{}) ([
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var results []bson.M
|
||||
var results []map[string]interface{}
|
||||
//pointers := make([]interface{}, len(columnNames))
|
||||
//rows.Next()
|
||||
for rows.Next() {
|
||||
recBson := bson.M{}
|
||||
recBson := make(map[string]interface{})
|
||||
columnPointers := make([]interface{}, len(columnNames))
|
||||
columns := make([]interface{}, len(columnNames))
|
||||
for idx := range columns {
|
||||
|
||||
@@ -700,7 +700,7 @@ func (dbobj SQLiteDB) CleanupRecord(t Tbl, keyName string, keyValue string, bdel
|
||||
}
|
||||
|
||||
// GetExpiring get records that are expiring
|
||||
func (dbobj SQLiteDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]bson.M, error) {
|
||||
func (dbobj SQLiteDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
now := int32(time.Now().Unix())
|
||||
q := fmt.Sprintf("select * from %s WHERE endtime>0 AND endtime<%d AND %s=$1",
|
||||
@@ -712,7 +712,7 @@ func (dbobj SQLiteDB) GetExpiring(t Tbl, keyName string, keyValue string) ([]bso
|
||||
}
|
||||
|
||||
// GetUniqueList returns a unique list of values from specific column in database
|
||||
func (dbobj SQLiteDB) GetUniqueList(t Tbl, keyName string) ([]bson.M, error) {
|
||||
func (dbobj SQLiteDB) GetUniqueList(t Tbl, keyName string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
keyName = dbobj.escapeName(keyName)
|
||||
q := "select distinct " + keyName + " from " + table + " ORDER BY " + keyName
|
||||
@@ -722,7 +722,7 @@ func (dbobj SQLiteDB) GetUniqueList(t Tbl, keyName string) ([]bson.M, error) {
|
||||
}
|
||||
|
||||
// GetList is used to return list of rows. It can be used to return values using pager.
|
||||
func (dbobj SQLiteDB) GetList0(t Tbl, start int32, limit int32, orderField string) ([]bson.M, error) {
|
||||
func (dbobj SQLiteDB) GetList0(t Tbl, start int32, limit int32, orderField string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
if limit > 100 {
|
||||
limit = 100
|
||||
@@ -744,7 +744,7 @@ func (dbobj SQLiteDB) GetList0(t Tbl, start int32, limit int32, orderField strin
|
||||
}
|
||||
|
||||
// GetList is used to return list of rows. It can be used to return values using pager.
|
||||
func (dbobj SQLiteDB) GetList(t Tbl, keyName string, keyValue string, start int32, limit int32, orderField string) ([]bson.M, error) {
|
||||
func (dbobj SQLiteDB) GetList(t Tbl, keyName string, keyValue string, start int32, limit int32, orderField string) ([]map[string]interface{}, error) {
|
||||
table := GetTable(t)
|
||||
if limit > 100 {
|
||||
limit = 100
|
||||
@@ -766,7 +766,7 @@ func (dbobj SQLiteDB) GetList(t Tbl, keyName string, keyValue string, start int3
|
||||
return dbobj.getListDo(q, values)
|
||||
}
|
||||
|
||||
func (dbobj SQLiteDB) getListDo(q string, values []interface{}) ([]bson.M, error) {
|
||||
func (dbobj SQLiteDB) getListDo(q string, values []interface{}) ([]map[string]interface{}, error) {
|
||||
tx, err := dbobj.db.Begin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -789,11 +789,11 @@ func (dbobj SQLiteDB) getListDo(q string, values []interface{}) ([]bson.M, error
|
||||
if err := rows.Err(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
var results []bson.M
|
||||
var results []map[string]interface{}
|
||||
//pointers := make([]interface{}, len(columnNames))
|
||||
//rows.Next()
|
||||
for rows.Next() {
|
||||
recBson := bson.M{}
|
||||
recBson := make(map[string]interface{})
|
||||
//fmt.Println("parsing result line")
|
||||
columnPointers := make([]interface{}, len(columnNames))
|
||||
//for i, _ := range columnNames {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
// Tbl is used to store table id
|
||||
@@ -95,10 +96,10 @@ type BackendDB interface {
|
||||
DeleteExpired0(Tbl, int32) (int64, error)
|
||||
DeleteExpired(Tbl, string, string) (int64, error)
|
||||
CleanupRecord(Tbl, string, string, []string) (int64, error)
|
||||
GetExpiring(Tbl, string, string) ([]bson.M, error)
|
||||
GetUniqueList(Tbl, string) ([]bson.M, error)
|
||||
GetList0(Tbl, int32, int32, string) ([]bson.M, error)
|
||||
GetList(Tbl, string, string, int32, int32, string) ([]bson.M, error)
|
||||
GetExpiring(Tbl, string, string) ([]map[string]interface{}, error)
|
||||
GetUniqueList(Tbl, string) ([]map[string]interface{}, error)
|
||||
GetList0(Tbl, int32, int32, string) ([]map[string]interface{}, error)
|
||||
GetList(Tbl, string, string, int32, int32, string) ([]map[string]interface{}, error)
|
||||
GetAllTables() ([]string, error)
|
||||
ValidateNewApp(appName string) bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user