github.com/Goboolean/common@v0.0.0-20231130153141-cb54596b217d/pkg/rdbms/queries.sql.go (about)

     1  // Code generated by sqlc. DO NOT EDIT.
     2  // versions:
     3  //   sqlc v1.19.1
     4  // source: queries.sql
     5  
     6  package rdbms
     7  
     8  import (
     9  	"context"
    10  	"database/sql"
    11  )
    12  
    13  const checkStockExist = `-- name: CheckStockExist :one
    14  SELECT EXISTS(SELECT 1 FROM product_meta WHERE id = ($1))
    15  `
    16  
    17  func (q *Queries) CheckStockExist(ctx context.Context, id string) (bool, error) {
    18  	row := q.db.QueryRowContext(ctx, checkStockExist, id)
    19  	var exists bool
    20  	err := row.Scan(&exists)
    21  	return exists, err
    22  }
    23  
    24  const createAccessInfo = `-- name: CreateAccessInfo :exec
    25  INSERT INTO store_log (product_id, "status") VALUES ($1, $2)
    26  `
    27  
    28  type CreateAccessInfoParams struct {
    29  	ProductID string
    30  	Status    string
    31  }
    32  
    33  func (q *Queries) CreateAccessInfo(ctx context.Context, arg CreateAccessInfoParams) error {
    34  	_, err := q.db.ExecContext(ctx, createAccessInfo, arg.ProductID, arg.Status)
    35  	return err
    36  }
    37  
    38  const deletePlatformInfo = `-- name: DeletePlatformInfo :exec
    39  DELETE FROM product_platform WHERE product_id = ($1) AND platform_name = ($2)
    40  `
    41  
    42  type DeletePlatformInfoParams struct {
    43  	ProductID    string
    44  	PlatformName string
    45  }
    46  
    47  func (q *Queries) DeletePlatformInfo(ctx context.Context, arg DeletePlatformInfoParams) error {
    48  	_, err := q.db.ExecContext(ctx, deletePlatformInfo, arg.ProductID, arg.PlatformName)
    49  	return err
    50  }
    51  
    52  const getAllStockMetaList = `-- name: GetAllStockMetaList :many
    53  SELECT id, "name", symbol, "description", "type", exchange,  "location"  FROM product_meta
    54  `
    55  
    56  func (q *Queries) GetAllStockMetaList(ctx context.Context) ([]ProductMetum, error) {
    57  	rows, err := q.db.QueryContext(ctx, getAllStockMetaList)
    58  	if err != nil {
    59  		return nil, err
    60  	}
    61  	defer rows.Close()
    62  	var items []ProductMetum
    63  	for rows.Next() {
    64  		var i ProductMetum
    65  		if err := rows.Scan(
    66  			&i.ID,
    67  			&i.Name,
    68  			&i.Symbol,
    69  			&i.Description,
    70  			&i.Type,
    71  			&i.Exchange,
    72  			&i.Location,
    73  		); err != nil {
    74  			return nil, err
    75  		}
    76  		items = append(items, i)
    77  	}
    78  	if err := rows.Close(); err != nil {
    79  		return nil, err
    80  	}
    81  	if err := rows.Err(); err != nil {
    82  		return nil, err
    83  	}
    84  	return items, nil
    85  }
    86  
    87  const getStockIdBySymbol = `-- name: GetStockIdBySymbol :one
    88  SELECT id FROM product_meta WHERE symbol = ($1)
    89  `
    90  
    91  func (q *Queries) GetStockIdBySymbol(ctx context.Context, symbol string) (string, error) {
    92  	row := q.db.QueryRowContext(ctx, getStockIdBySymbol, symbol)
    93  	var id string
    94  	err := row.Scan(&id)
    95  	return id, err
    96  }
    97  
    98  const getStockMeta = `-- name: GetStockMeta :one
    99  SELECT id, "name", symbol, "description", "type", exchange,  "location"  FROM product_meta WHERE id = ($1)
   100  `
   101  
   102  func (q *Queries) GetStockMeta(ctx context.Context, id string) (ProductMetum, error) {
   103  	row := q.db.QueryRowContext(ctx, getStockMeta, id)
   104  	var i ProductMetum
   105  	err := row.Scan(
   106  		&i.ID,
   107  		&i.Name,
   108  		&i.Symbol,
   109  		&i.Description,
   110  		&i.Type,
   111  		&i.Exchange,
   112  		&i.Location,
   113  	)
   114  	return i, err
   115  }
   116  
   117  const getStockMetaWithPlatform = `-- name: GetStockMetaWithPlatform :one
   118  SELECT product_meta.id, "name", symbol, "description", "type", exchange,  "location" , platform_name, identifier 
   119  FROM product_meta 
   120  JOIN product_platform 
   121  ON product_meta.id = product_platform.product_id 
   122  WHERE product_meta.id = ($1)
   123  `
   124  
   125  type GetStockMetaWithPlatformRow struct {
   126  	ID           string
   127  	Name         string
   128  	Symbol       string
   129  	Description  sql.NullString
   130  	Type         string
   131  	Exchange     string
   132  	Location     sql.NullString
   133  	PlatformName string
   134  	Identifier   string
   135  }
   136  
   137  func (q *Queries) GetStockMetaWithPlatform(ctx context.Context, id string) (GetStockMetaWithPlatformRow, error) {
   138  	row := q.db.QueryRowContext(ctx, getStockMetaWithPlatform, id)
   139  	var i GetStockMetaWithPlatformRow
   140  	err := row.Scan(
   141  		&i.ID,
   142  		&i.Name,
   143  		&i.Symbol,
   144  		&i.Description,
   145  		&i.Type,
   146  		&i.Exchange,
   147  		&i.Location,
   148  		&i.PlatformName,
   149  		&i.Identifier,
   150  	)
   151  	return i, err
   152  }
   153  
   154  const insertNewStockMeta = `-- name: InsertNewStockMeta :exec
   155  INSERT INTO product_meta (id, "name", symbol, "description", "type", exchange, "location") 
   156  VALUES ($1, $2, $3, $4, $5, $6, $7)
   157  `
   158  
   159  type InsertNewStockMetaParams struct {
   160  	ID          string
   161  	Name        string
   162  	Symbol      string
   163  	Description sql.NullString
   164  	Type        string
   165  	Exchange    string
   166  	Location    sql.NullString
   167  }
   168  
   169  func (q *Queries) InsertNewStockMeta(ctx context.Context, arg InsertNewStockMetaParams) error {
   170  	_, err := q.db.ExecContext(ctx, insertNewStockMeta,
   171  		arg.ID,
   172  		arg.Name,
   173  		arg.Symbol,
   174  		arg.Description,
   175  		arg.Type,
   176  		arg.Exchange,
   177  		arg.Location,
   178  	)
   179  	return err
   180  }
   181  
   182  const insertNewStockPlatformMeta = `-- name: InsertNewStockPlatformMeta :exec
   183  INSERT INTO product_platform (product_id, platform_name, identifier)
   184  VALUES ($1, $2, $3)
   185  `
   186  
   187  type InsertNewStockPlatformMetaParams struct {
   188  	ProductID    string
   189  	PlatformName string
   190  	Identifier   string
   191  }
   192  
   193  func (q *Queries) InsertNewStockPlatformMeta(ctx context.Context, arg InsertNewStockPlatformMetaParams) error {
   194  	_, err := q.db.ExecContext(ctx, insertNewStockPlatformMeta, arg.ProductID, arg.PlatformName, arg.Identifier)
   195  	return err
   196  }
   197  
   198  const insertPlatformInfo = `-- name: InsertPlatformInfo :exec
   199  INSERT INTO product_platform (product_id, platform_name, identifier) VALUES ($1, $2, $3)
   200  `
   201  
   202  type InsertPlatformInfoParams struct {
   203  	ProductID    string
   204  	PlatformName string
   205  	Identifier   string
   206  }
   207  
   208  func (q *Queries) InsertPlatformInfo(ctx context.Context, arg InsertPlatformInfoParams) error {
   209  	_, err := q.db.ExecContext(ctx, insertPlatformInfo, arg.ProductID, arg.PlatformName, arg.Identifier)
   210  	return err
   211  }
   212  
   213  const updatePlatformIdentifier = `-- name: UpdatePlatformIdentifier :exec
   214  UPDATE product_platform SET identifier = ($1) WHERE product_id = ($2) AND platform_name = ($3)
   215  `
   216  
   217  type UpdatePlatformIdentifierParams struct {
   218  	Identifier   string
   219  	ProductID    string
   220  	PlatformName string
   221  }
   222  
   223  func (q *Queries) UpdatePlatformIdentifier(ctx context.Context, arg UpdatePlatformIdentifierParams) error {
   224  	_, err := q.db.ExecContext(ctx, updatePlatformIdentifier, arg.Identifier, arg.ProductID, arg.PlatformName)
   225  	return err
   226  }