53ea7d34e6
Start adding Textract + UUID changes * base * startclient * ts * short * tests
131 lines
3.5 KiB
Go
131 lines
3.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: text.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const addDocumentText = `-- name: AddDocumentText :one
|
|
INSERT INTO documentTextExtractions (bucket, key, cleanEntryId, hash) VALUES ($1, $2, $3, $4) returning id
|
|
`
|
|
|
|
type AddDocumentTextParams struct {
|
|
Bucket string `db:"bucket"`
|
|
Key string `db:"key"`
|
|
Cleanentryid uuid.UUID `db:"cleanentryid"`
|
|
Hash string `db:"hash"`
|
|
}
|
|
|
|
// AddDocumentText
|
|
//
|
|
// INSERT INTO documentTextExtractions (bucket, key, cleanEntryId, hash) VALUES ($1, $2, $3, $4) returning id
|
|
func (q *Queries) AddDocumentText(ctx context.Context, arg *AddDocumentTextParams) (uuid.UUID, error) {
|
|
row := q.db.QueryRow(ctx, addDocumentText,
|
|
arg.Bucket,
|
|
arg.Key,
|
|
arg.Cleanentryid,
|
|
arg.Hash,
|
|
)
|
|
var id uuid.UUID
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const addDocumentTextEntry = `-- name: AddDocumentTextEntry :exec
|
|
INSERT INTO documentTextExtractionEntries (textId, version) VALUES ($1, $2)
|
|
`
|
|
|
|
type AddDocumentTextEntryParams struct {
|
|
Textid uuid.UUID `db:"textid"`
|
|
Version int64 `db:"version"`
|
|
}
|
|
|
|
// AddDocumentTextEntry
|
|
//
|
|
// INSERT INTO documentTextExtractionEntries (textId, version) VALUES ($1, $2)
|
|
func (q *Queries) AddDocumentTextEntry(ctx context.Context, arg *AddDocumentTextEntryParams) error {
|
|
_, err := q.db.Exec(ctx, addDocumentTextEntry, arg.Textid, arg.Version)
|
|
return err
|
|
}
|
|
|
|
const getDocumentTextExtractionByHash = `-- name: GetDocumentTextExtractionByHash :one
|
|
SELECT id, documentId, bucket, key, version, hash, cleanEntryId
|
|
FROM currentTextEntries
|
|
WHERE cleanEntryId = $1 and hash = $2
|
|
`
|
|
|
|
type GetDocumentTextExtractionByHashParams struct {
|
|
Cleanentryid uuid.UUID `db:"cleanentryid"`
|
|
Hash string `db:"hash"`
|
|
}
|
|
|
|
// GetDocumentTextExtractionByHash
|
|
//
|
|
// SELECT id, documentId, bucket, key, version, hash, cleanEntryId
|
|
// FROM currentTextEntries
|
|
// WHERE cleanEntryId = $1 and hash = $2
|
|
func (q *Queries) GetDocumentTextExtractionByHash(ctx context.Context, arg *GetDocumentTextExtractionByHashParams) (*Currenttextentry, error) {
|
|
row := q.db.QueryRow(ctx, getDocumentTextExtractionByHash, arg.Cleanentryid, arg.Hash)
|
|
var i Currenttextentry
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Documentid,
|
|
&i.Bucket,
|
|
&i.Key,
|
|
&i.Version,
|
|
&i.Hash,
|
|
&i.Cleanentryid,
|
|
)
|
|
return &i, err
|
|
}
|
|
|
|
const getTextEntryByDocId = `-- name: GetTextEntryByDocId :one
|
|
SELECT id, documentId, bucket, key, version, hash, cleanEntryId
|
|
FROM currentTextEntries
|
|
WHERE documentId = $1
|
|
`
|
|
|
|
// GetTextEntryByDocId
|
|
//
|
|
// SELECT id, documentId, bucket, key, version, hash, cleanEntryId
|
|
// FROM currentTextEntries
|
|
// WHERE documentId = $1
|
|
func (q *Queries) GetTextEntryByDocId(ctx context.Context, documentid uuid.UUID) (*Currenttextentry, error) {
|
|
row := q.db.QueryRow(ctx, getTextEntryByDocId, documentid)
|
|
var i Currenttextentry
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Documentid,
|
|
&i.Bucket,
|
|
&i.Key,
|
|
&i.Version,
|
|
&i.Hash,
|
|
&i.Cleanentryid,
|
|
)
|
|
return &i, err
|
|
}
|
|
|
|
const isDocumentTextExtracted = `-- name: IsDocumentTextExtracted :one
|
|
SELECT EXISTS(
|
|
SELECT 1 FROM currentTextEntries WHERE documentId = $1
|
|
)
|
|
`
|
|
|
|
// IsDocumentTextExtracted
|
|
//
|
|
// SELECT EXISTS(
|
|
// SELECT 1 FROM currentTextEntries WHERE documentId = $1
|
|
// )
|
|
func (q *Queries) IsDocumentTextExtracted(ctx context.Context, documentid uuid.UUID) (bool, error) {
|
|
row := q.db.QueryRow(ctx, isDocumentTextExtracted, documentid)
|
|
var exists bool
|
|
err := row.Scan(&exists)
|
|
return exists, err
|
|
}
|