mirror of
https://github.com/gofiber/storage.git
synced 2025-10-04 08:16:36 +08:00
Moved new postgres implementation to v2 folder, also added nil check for db object in postgres config
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package postgres
|
||||
package v2
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"github.com/jackc/pgx/pgxpool"
|
||||
"time"
|
||||
)
|
||||
|
@@ -1,10 +1,12 @@
|
||||
package postgres
|
||||
package v2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -45,6 +47,10 @@ func New(config ...Config) *Storage {
|
||||
|
||||
db := cfg.Db
|
||||
|
||||
if reflect.ValueOf(db).IsNil() {
|
||||
panic(errors.New("db pool instance must be passed into the config"))
|
||||
}
|
||||
|
||||
// Ping database
|
||||
if err := db.Ping(context.Background()); err != nil {
|
||||
panic(err)
|
@@ -1,4 +1,4 @@
|
||||
package postgres
|
||||
package v2
|
||||
|
||||
import (
|
||||
"context"
|
Reference in New Issue
Block a user