swuecho / sqlc-fs

sqlc (postgresql) plugin for f#
0 stars 0 forks source link

sqlc-fs

sqlc-fs is a sqlc plugin to generate queries that are compatible with Npgsql.Fsharp.

This plugin is in alpha stage.

check https://github.com/swuecho/sqlc-fs/tree/main/testdata for demo.

Installation & Usage

go install github.com/swuecho/sqlc-fs@latest
// sqlc.json
{
  "version": "2",
  "plugins": [
    {
      "name": "fs",
      "process": {
        "cmd": "sqlc-fs"
      }
    }
  ],
   "sql": [
    {
      "schema": "schema.sql",
      "queries": "query/",
      "engine": "postgresql",
      "codegen": [
        {
          "out": "gen",
          "plugin": "fs",
          "options": {
            // options with default value
            // "emit_async_code": false,
            // "emit_auto_open_model": true,
            // "emit_model_file_name": "model_from_schema.fs",
            // "emit_model_name: "ModelFromSchema",
          }
        }
      ]
    }
  ]

Dev & Contribution

go build -o bin/sqlc-ts 

See testdata/ for a full example that can be run with:

sqlc generate -f ./testdata/sqlc.json

CREDIT

the plugin is based on sqlc-ts, which is a very good starting point to write sqlc plugin.