Merged in feature/clientexternalid (pull request #99)

Client External ID

* normalizeexternalid

* cleanopenapi

* cleanopenapi

* changingpublic

* noprecommit

* testing

* precommit

* processtest

* nodb

* tests

* tests
This commit is contained in:
Michael McGuinness
2025-03-11 16:31:06 +00:00
parent 8e4d66a998
commit 6648cdf1cb
68 changed files with 5171 additions and 1106 deletions
+21 -11
View File
@@ -139,9 +139,14 @@ func (q *Queries) ListDocumentIDsBatch(ctx context.Context, arg *ListDocumentIDs
return items, nil
}
const listDocumentsByClientId = `-- name: ListDocumentsByClientId :many
WITH docs as (
SELECT id from documents where clientId = $1
const listDocumentsByClientExternalId = `-- name: ListDocumentsByClientExternalId :many
WITH client as (
SELECT id from clients where externalId = $1
),
docs as (
SELECT d.id
from documents as d
JOIN client as c on d.clientId = c.id
),
entries as (
SELECT
@@ -155,16 +160,21 @@ entries as (
SELECT documentId as id, bucket, key from entries WHERE rowNumber = 1
`
type ListDocumentsByClientIdRow struct {
type ListDocumentsByClientExternalIdRow struct {
ID pgtype.UUID `db:"id"`
Bucket string `db:"bucket"`
Key string `db:"key"`
}
// ListDocumentsByClientId
// ListDocumentsByClientExternalId
//
// WITH docs as (
// SELECT id from documents where clientId = $1
// WITH client as (
// SELECT id from clients where externalId = $1
// ),
// docs as (
// SELECT d.id
// from documents as d
// JOIN client as c on d.clientId = c.id
// ),
// entries as (
// SELECT
@@ -176,15 +186,15 @@ type ListDocumentsByClientIdRow struct {
// JOIN documentEntries de on d.id = de.documentId
// )
// SELECT documentId as id, bucket, key from entries WHERE rowNumber = 1
func (q *Queries) ListDocumentsByClientId(ctx context.Context, clientid pgtype.UUID) ([]*ListDocumentsByClientIdRow, error) {
rows, err := q.db.Query(ctx, listDocumentsByClientId, clientid)
func (q *Queries) ListDocumentsByClientExternalId(ctx context.Context, clientid string) ([]*ListDocumentsByClientExternalIdRow, error) {
rows, err := q.db.Query(ctx, listDocumentsByClientExternalId, clientid)
if err != nil {
return nil, err
}
defer rows.Close()
items := []*ListDocumentsByClientIdRow{}
items := []*ListDocumentsByClientExternalIdRow{}
for rows.Next() {
var i ListDocumentsByClientIdRow
var i ListDocumentsByClientExternalIdRow
if err := rows.Scan(&i.ID, &i.Bucket, &i.Key); err != nil {
return nil, err
}