mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
506 B
19 lines
506 B
2 years ago
|
// Copyright 2023 ROC. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package types
|
||
|
|
||
|
import (
|
||
|
"github.com/jackc/pgx/v5/pgtype"
|
||
|
)
|
||
|
|
||
|
// PgxArray returns an object usable by pg drivers for passing a []T slice
|
||
|
// into a database as type T[].
|
||
|
func PgxArray[T any](elements []T) pgtype.Array[T] {
|
||
|
return pgtype.Array[T]{
|
||
|
Elements: elements,
|
||
|
Dims: []pgtype.ArrayDimension{{Length: int32(len(elements)), LowerBound: 1}},
|
||
|
}
|
||
|
}
|