Skip to content

Commit

Permalink
chore(docs): adding missing areas to the readme (#81)
Browse files Browse the repository at this point in the history
adding missing areas to the readme
  • Loading branch information
Jacobbrewer1 authored Jan 15, 2025
1 parent 8d5b5fd commit b5539b9
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,38 @@ of the need to generate patches for a database; when a new field is added to a s
new `if` checks to be created in the codebase. This library aims to solve that problem by generating the SQL patches for
you.

## What is Patcher?

* **Automatic SQL Generation**: It automatically generates SQL UPDATE queries from structs, reducing the need for
manually
writing and maintaining SQL statements.
* **Code Simplification**: It reduces the amount of boilerplate code and if-else conditions required to handle different
struct fields, making the codebase cleaner and easier to maintain.
* **Struct Diffs**: It allows injecting changes from one struct to another and generating update scripts based on
differences, streamlining the process of synchronizing data changes.
* **Join Support**: It supports generating SQL joins by creating structs that implement the Joiner interface,
simplifying
the process of managing related data across multiple tables.

## Usage

### Configuration

#### LoadDiff Options

* `includeZeroValues`: Set to true to include zero values in the diff.
* `includeNilValues`: Set to true to include nil values in the diff.

#### GenerateSQL Options

* `WithTable(tableName string)`: Specify the table name for the SQL query.
* `WithWhere(whereClause WhereTyper)`: Provide a where clause for the SQL query.
* `WithJoin(joinClause Joiner)`: Add join clauses to the SQL query.
* `includeZeroValues`: Set to true to include zero values in the diff. (Only for NewDiffSQLPatch)
* `includeNilValues`: Set to true to include nil values in the diff. (Only for NewDiffSQLPatch)

### Basic Examples

#### Basic

To use the library, you need to create a struct that represents the table you want to generate patches for. The struct
Expand Down Expand Up @@ -254,6 +284,34 @@ the [Joiner](./joiner.go) interface.
Once you have the join struct, you can pass it to the `GenerateSQL` function using the `WithJoin` option. You can add as
many of these as you would like.

# Examples
## Installation

To install the Patcher library, use the following command:

```sh
go get github.com/jacobbrewer1/patcher
```

## Examples

You can find examples of how to use this library in the [examples](./examples) directory.

## Contributing

We welcome contributions! Please follow these steps to contribute:

1. Fork the repository.
2. Create a new branch for your feature or bugfix.
3. Write tests for your changes.
4. Run the tests to ensure everything works.
5. Submit a pull request.

To run tests, use the following command:

```sh
go test ./...
```

## License

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.

0 comments on commit b5539b9

Please sign in to comment.