Skip to content

Option to output additional read only client #694

Answered by kyleconroy
abatilo asked this question in General
Discussion options

You must be logged in to vote

Hey, thanks for the suggestion. This is a really good idea.

I think we can get away with generating a read-only interface instead of a different struct. Here's a simple example, given the following two input files:

-- query.sql
CREATE TABLE foo (bar text);

-- name: ListFoo :many
SELECT * FROM foo;

-- name: CreateFoo :exec
INSERT INTO foo (bar) VALUES ($1);
{
  "version": "1",
  "packages": [
    {
      "path": "go",
      "name": "db",
      "schema": "query.sql",
      "queries": "query.sql",
      "engine": "postgresql",
      "emit_interface": true
    }
  ]
}

Today, this generates the following four Go files:

// Code generated by sqlc. DO NOT EDIT.
// models.go

package db

import (
	

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@abatilo
Comment options

Answer selected by abatilo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #694 on August 29, 2020 16:20.