canonical / sqlair

Friendly type mapping for SQL databases
Apache License 2.0
17 stars 9 forks source link

Add Library Interface #44

Closed Aflynn50 closed 1 year ago

Aflynn50 commented 1 year ago

This PR adds the sqlair.go file. This file contains all the public methods that will be exposed as the library API.

It also contains PR #42.

The public interface contains a Statement, a DB and a Query type. The statement represents a prepared SQLair statement. The DB is a database that can execute queries that include SQLair DML and the Query represents the query and iterates over the results.

Following the spec we use a pattern of iteration over the Query where errors are not immediately returned. Instead, Next and Decode return a boolean and if an error is encountered. The error can then be checked with Query.Err().

Close must be called once iteration over the rows has finished. It is called implicitly if Next or Decode return false.