diff --git a/src/storage/mysql-storage.go b/src/storage/mysql-storage.go index f1bb296..62a334f 100644 --- a/src/storage/mysql-storage.go +++ b/src/storage/mysql-storage.go @@ -458,7 +458,7 @@ func (dbobj MySQLDB) LookupRecord(t Tbl, row bson.M) (bson.M, error) { values = append(values, keyValue) num = num + 1 } - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } // GetRecord returns specific record from database @@ -467,15 +467,15 @@ func (dbobj MySQLDB) GetRecord(t Tbl, keyName string, keyValue string) (bson.M, q := "select * from " + table + " WHERE " + dbobj.escapeName(keyName) + "=?" values := make([]interface{}, 0) values = append(values, keyValue) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } -// GetRecordInTable returns specific record from database -func (dbobj MySQLDB) GetRecordInTable(table string, keyName string, keyValue string) (bson.M, error) { +// GetRecordFromTable returns specific record from database +func (dbobj MySQLDB) GetRecordFromTable(table string, keyName string, keyValue string) (bson.M, error) { q := "select * from " + table + " WHERE " + dbobj.escapeName(keyName) + "=?" values := make([]interface{}, 0) values = append(values, keyValue) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } // GetRecord2 returns specific record from database @@ -487,10 +487,10 @@ func (dbobj MySQLDB) GetRecord2(t Tbl, keyName string, keyValue string, values := make([]interface{}, 0) values = append(values, keyValue) values = append(values, keyValue2) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } -func (dbobj MySQLDB) getRecordInTableDo(q string, values []interface{}) (bson.M, error) { +func (dbobj MySQLDB) getOneRecord(q string, values []interface{}) (bson.M, error) { //fmt.Printf("query: %s\n", q) tx, err := dbobj.db.Begin() diff --git a/src/storage/pgsql-storage.go b/src/storage/pgsql-storage.go index 606b2ce..b5d6869 100644 --- a/src/storage/pgsql-storage.go +++ b/src/storage/pgsql-storage.go @@ -456,7 +456,7 @@ func (dbobj PGSQLDB) LookupRecord(t Tbl, row bson.M) (bson.M, error) { values = append(values, keyValue) num = num + 1 } - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } // GetRecord returns specific record from database @@ -465,15 +465,15 @@ func (dbobj PGSQLDB) GetRecord(t Tbl, keyName string, keyValue string) (bson.M, q := "select * from " + table + " WHERE " + dbobj.escapeName(keyName) + "=$1" values := make([]interface{}, 0) values = append(values, keyValue) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } -// GetRecordInTable returns specific record from database -func (dbobj PGSQLDB) GetRecordInTable(table string, keyName string, keyValue string) (bson.M, error) { +// GetRecordFromTable returns specific record from database +func (dbobj PGSQLDB) GetRecordFromTable(table string, keyName string, keyValue string) (bson.M, error) { q := "select * from " + table + " WHERE " + dbobj.escapeName(keyName) + "=$1" values := make([]interface{}, 0) values = append(values, keyValue) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } // GetRecord2 returns specific record from database @@ -485,10 +485,10 @@ func (dbobj PGSQLDB) GetRecord2(t Tbl, keyName string, keyValue string, values := make([]interface{}, 0) values = append(values, keyValue) values = append(values, keyValue2) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } -func (dbobj PGSQLDB) getRecordInTableDo(q string, values []interface{}) (bson.M, error) { +func (dbobj PGSQLDB) getOneRecord(q string, values []interface{}) (bson.M, error) { //fmt.Printf("query: %s\n", q) tx, err := dbobj.db.Begin() diff --git a/src/storage/sqlite-storage.go b/src/storage/sqlite-storage.go index e38c3ea..5c00030 100644 --- a/src/storage/sqlite-storage.go +++ b/src/storage/sqlite-storage.go @@ -445,7 +445,7 @@ func (dbobj SQLiteDB) LookupRecord(t Tbl, row bson.M) (bson.M, error) { values = append(values, keyValue) num = num + 1 } - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } // GetRecord returns specific record from database @@ -454,15 +454,15 @@ func (dbobj SQLiteDB) GetRecord(t Tbl, keyName string, keyValue string) (bson.M, q := "select * from " + table + " WHERE " + dbobj.escapeName(keyName) + "=$1" values := make([]interface{}, 0) values = append(values, keyValue) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } -// GetRecordInTable returns specific record from database -func (dbobj SQLiteDB) GetRecordInTable(table string, keyName string, keyValue string) (bson.M, error) { +// GetRecordFromTable returns specific record from database +func (dbobj SQLiteDB) GetRecordFromTable(table string, keyName string, keyValue string) (bson.M, error) { q := "select * from " + table + " WHERE " + dbobj.escapeName(keyName) + "=$1" values := make([]interface{}, 0) values = append(values, keyValue) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } // GetRecord2 returns specific record from database @@ -474,10 +474,10 @@ func (dbobj SQLiteDB) GetRecord2(t Tbl, keyName string, keyValue string, values := make([]interface{}, 0) values = append(values, keyValue) values = append(values, keyValue2) - return dbobj.getRecordInTableDo(q, values) + return dbobj.getOneRecord(q, values) } -func (dbobj SQLiteDB) getRecordInTableDo(q string, values []interface{}) (bson.M, error) { +func (dbobj SQLiteDB) getOneRecord(q string, values []interface{}) (bson.M, error) { //fmt.Printf("query: %s\n", q) tx, err := dbobj.db.Begin() diff --git a/src/storage/storage.go b/src/storage/storage.go index f998301..3de9f17 100644 --- a/src/storage/storage.go +++ b/src/storage/storage.go @@ -87,7 +87,7 @@ type BackendDB interface { UpdateRecordInTable2(string, string, string, string, string, *bson.M, *bson.M) (int64, error) LookupRecord(Tbl, bson.M) (bson.M, error) GetRecord(Tbl, string, string) (bson.M, error) - GetRecordInTable(string, string, string) (bson.M, error) + GetRecordFromTable(string, string, string) (bson.M, error) GetRecord2(Tbl, string, string, string, string) (bson.M, error) DeleteRecord(Tbl, string, string) (int64, error) DeleteRecordInTable(string, string, string) (int64, error) diff --git a/src/userapps_db.go b/src/userapps_db.go index 7a84e0c..85a4642 100644 --- a/src/userapps_db.go +++ b/src/userapps_db.go @@ -17,7 +17,7 @@ func (dbobj dbcon) getUserApp(userTOKEN string, appName string, conf Config) ([] var record bson.M var err error if conf.Generic.UseSeparateAppTables == true { - record, err = dbobj.store.GetRecordInTable(appNameFull, "token", userTOKEN) + record, err = dbobj.store.GetRecordFromTable(appNameFull, "token", userTOKEN) } else { record, err = dbobj.store.GetRecord2(storage.TblName.Userapps, "token", userTOKEN, "appname", appName) } @@ -78,7 +78,7 @@ func (dbobj dbcon) createAppRecord(jsonData []byte, userTOKEN string, appName st } //fmt.Println("creating new app") if conf.Generic.UseSeparateAppTables == true { - record, err := dbobj.store.GetRecordInTable(appNameFull, "token", userTOKEN) + record, err := dbobj.store.GetRecordFromTable(appNameFull, "token", userTOKEN) if err != nil { return userTOKEN, err } @@ -118,7 +118,7 @@ func (dbobj dbcon) updateAppRecord(jsonDataPatch []byte, userTOKEN string, appNa } var record bson.M if conf.Generic.UseSeparateAppTables == true { - record, err = dbobj.store.GetRecordInTable(appNameFull, "token", userTOKEN) + record, err = dbobj.store.GetRecordFromTable(appNameFull, "token", userTOKEN) } else { record, err = dbobj.store.GetRecord2(storage.TblName.Userapps, "token", userTOKEN, "appname", appName) } @@ -208,7 +208,7 @@ func (dbobj dbcon) listUserApps(userTOKEN string, conf Config) ([]byte, error) { var result []string for _, colName := range allCollections { if strings.HasPrefix(colName, "app_") { - record, err := dbobj.store.GetRecordInTable(colName, "token", userTOKEN) + record, err := dbobj.store.GetRecordFromTable(colName, "token", userTOKEN) if err != nil { return nil, err } @@ -247,7 +247,7 @@ func (dbobj dbcon) dumpUserApps(userTOKEN string, conf Config) ([]byte, error) { } for _, colName := range allCollections { if strings.HasPrefix(colName, "app_") { - record, err := dbobj.store.GetRecordInTable(colName, "token", userTOKEN) + record, err := dbobj.store.GetRecordFromTable(colName, "token", userTOKEN) if err != nil { return nil, err }