storj/private/dbutil/pgutil/data.go

20 lines
498 B
Go
Raw Normal View History

2019-02-14 13:33:42 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package pgutil
import (
"context"
2019-02-14 13:33:42 +00:00
"strconv"
"storj.io/storj/private/dbutil/dbschema"
2019-02-14 13:33:42 +00:00
)
// QueryData loads all data from tables.
func QueryData(ctx context.Context, db dbschema.Queryer, schema *dbschema.Schema) (*dbschema.Data, error) {
return dbschema.QueryData(ctx, db, schema, func(columnName string) string {
2019-02-14 13:33:42 +00:00
quoted := strconv.Quote(columnName)
return `quote_nullable(` + quoted + `) as ` + quoted
})
}