Skip to content

Commit 0c5eb66

Browse files
author
Nicolás Parada
committed
add git files
1 parent fb7b7a8 commit 0c5eb66

File tree

3 files changed

+315
-0
lines changed

3 files changed

+315
-0
lines changed

.gitignore

+267
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/macos,windows,linux,go,visualstudiocode,goland,vim,dotenv,executable
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,linux,go,visualstudiocode,goland,vim,dotenv,executable
3+
4+
### dotenv ###
5+
.env
6+
7+
### Executable ###
8+
*.app
9+
*.bat
10+
*.cgi
11+
*.com
12+
*.exe
13+
*.gadget
14+
*.jar
15+
*.pif
16+
*.vb
17+
*.wsf
18+
19+
### Go ###
20+
# If you prefer the allow list template instead of the deny list, see community template:
21+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
22+
#
23+
# Binaries for programs and plugins
24+
*.exe~
25+
*.dll
26+
*.so
27+
*.dylib
28+
29+
# Test binary, built with `go test -c`
30+
*.test
31+
32+
# Output of the go coverage tool, specifically when used with LiteIDE
33+
*.out
34+
35+
# Dependency directories (remove the comment below to include it)
36+
# vendor/
37+
38+
# Go workspace file
39+
go.work
40+
41+
### GoLand ###
42+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
43+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
44+
45+
# User-specific stuff
46+
.idea/**/workspace.xml
47+
.idea/**/tasks.xml
48+
.idea/**/usage.statistics.xml
49+
.idea/**/dictionaries
50+
.idea/**/shelf
51+
52+
# AWS User-specific
53+
.idea/**/aws.xml
54+
55+
# Generated files
56+
.idea/**/contentModel.xml
57+
58+
# Sensitive or high-churn files
59+
.idea/**/dataSources/
60+
.idea/**/dataSources.ids
61+
.idea/**/dataSources.local.xml
62+
.idea/**/sqlDataSources.xml
63+
.idea/**/dynamic.xml
64+
.idea/**/uiDesigner.xml
65+
.idea/**/dbnavigator.xml
66+
67+
# Gradle
68+
.idea/**/gradle.xml
69+
.idea/**/libraries
70+
71+
# Gradle and Maven with auto-import
72+
# When using Gradle or Maven with auto-import, you should exclude module files,
73+
# since they will be recreated, and may cause churn. Uncomment if using
74+
# auto-import.
75+
# .idea/artifacts
76+
# .idea/compiler.xml
77+
# .idea/jarRepositories.xml
78+
# .idea/modules.xml
79+
# .idea/*.iml
80+
# .idea/modules
81+
# *.iml
82+
# *.ipr
83+
84+
# CMake
85+
cmake-build-*/
86+
87+
# Mongo Explorer plugin
88+
.idea/**/mongoSettings.xml
89+
90+
# File-based project format
91+
*.iws
92+
93+
# IntelliJ
94+
out/
95+
96+
# mpeltonen/sbt-idea plugin
97+
.idea_modules/
98+
99+
# JIRA plugin
100+
atlassian-ide-plugin.xml
101+
102+
# Cursive Clojure plugin
103+
.idea/replstate.xml
104+
105+
# SonarLint plugin
106+
.idea/sonarlint/
107+
108+
# Crashlytics plugin (for Android Studio and IntelliJ)
109+
com_crashlytics_export_strings.xml
110+
crashlytics.properties
111+
crashlytics-build.properties
112+
fabric.properties
113+
114+
# Editor-based Rest Client
115+
.idea/httpRequests
116+
117+
# Android studio 3.1+ serialized cache file
118+
.idea/caches/build_file_checksums.ser
119+
120+
### GoLand Patch ###
121+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
122+
123+
# *.iml
124+
# modules.xml
125+
# .idea/misc.xml
126+
# *.ipr
127+
128+
# Sonarlint plugin
129+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
130+
.idea/**/sonarlint/
131+
132+
# SonarQube Plugin
133+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
134+
.idea/**/sonarIssues.xml
135+
136+
# Markdown Navigator plugin
137+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
138+
.idea/**/markdown-navigator.xml
139+
.idea/**/markdown-navigator-enh.xml
140+
.idea/**/markdown-navigator/
141+
142+
# Cache file creation bug
143+
# See https://youtrack.jetbrains.com/issue/JBR-2257
144+
.idea/$CACHE_FILE$
145+
146+
# CodeStream plugin
147+
# https://plugins.jetbrains.com/plugin/12206-codestream
148+
.idea/codestream.xml
149+
150+
# Azure Toolkit for IntelliJ plugin
151+
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
152+
.idea/**/azureSettings.xml
153+
154+
### Linux ###
155+
*~
156+
157+
# temporary files which can be created if a process still has a handle open of a deleted file
158+
.fuse_hidden*
159+
160+
# KDE directory preferences
161+
.directory
162+
163+
# Linux trash folder which might appear on any partition or disk
164+
.Trash-*
165+
166+
# .nfs files are created when an open file is removed but is still being accessed
167+
.nfs*
168+
169+
### macOS ###
170+
# General
171+
.DS_Store
172+
.AppleDouble
173+
.LSOverride
174+
175+
# Icon must end with two \r
176+
Icon
177+
178+
179+
# Thumbnails
180+
._*
181+
182+
# Files that might appear in the root of a volume
183+
.DocumentRevisions-V100
184+
.fseventsd
185+
.Spotlight-V100
186+
.TemporaryItems
187+
.Trashes
188+
.VolumeIcon.icns
189+
.com.apple.timemachine.donotpresent
190+
191+
# Directories potentially created on remote AFP share
192+
.AppleDB
193+
.AppleDesktop
194+
Network Trash Folder
195+
Temporary Items
196+
.apdisk
197+
198+
### macOS Patch ###
199+
# iCloud generated files
200+
*.icloud
201+
202+
### Vim ###
203+
# Swap
204+
[._]*.s[a-v][a-z]
205+
!*.svg # comment out if you don't need vector files
206+
[._]*.sw[a-p]
207+
[._]s[a-rt-v][a-z]
208+
[._]ss[a-gi-z]
209+
[._]sw[a-p]
210+
211+
# Session
212+
Session.vim
213+
Sessionx.vim
214+
215+
# Temporary
216+
.netrwhist
217+
# Auto-generated tag files
218+
tags
219+
# Persistent undo
220+
[._]*.un~
221+
222+
### VisualStudioCode ###
223+
.vscode/*
224+
!.vscode/settings.json
225+
!.vscode/tasks.json
226+
!.vscode/launch.json
227+
!.vscode/extensions.json
228+
!.vscode/*.code-snippets
229+
230+
# Local History for Visual Studio Code
231+
.history/
232+
233+
# Built Visual Studio Code Extensions
234+
*.vsix
235+
236+
### VisualStudioCode Patch ###
237+
# Ignore all local history of files
238+
.history
239+
.ionide
240+
241+
### Windows ###
242+
# Windows thumbnail cache files
243+
Thumbs.db
244+
Thumbs.db:encryptable
245+
ehthumbs.db
246+
ehthumbs_vista.db
247+
248+
# Dump file
249+
*.stackdump
250+
251+
# Folder config file
252+
[Dd]esktop.ini
253+
254+
# Recycle Bin used on file shares
255+
$RECYCLE.BIN/
256+
257+
# Windows Installer files
258+
*.cab
259+
*.msi
260+
*.msix
261+
*.msm
262+
*.msp
263+
264+
# Windows shortcuts
265+
*.lnk
266+
267+
# End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,go,visualstudiocode,goland,vim,dotenv,executable

LICENSE

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ISC License
2+
3+
Copyright (c) 2023 Nicolás Parada
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15+
PERFORMANCE OF THIS SOFTWARE.

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Golang Database Wrapper
2+
3+
```bash
4+
go get github.com/nicolasparada/go-db
5+
```
6+
7+
Simple Golang database wrapper over [github.com/jackc/pgx/v5](https://github.com/jackc/pgx/v5) with better transactions API.
8+
9+
Instead of starting a transaction, commiting (or rolling back) each time,
10+
you simply pass a callback function. This allows for definig methods
11+
over a single database object and you can either run them standalone
12+
or inside a transaction.
13+
14+
```go
15+
type Repo struct {
16+
db *db.DB
17+
}
18+
19+
func (repo *Repo) Insert(ctx context.Context) error {
20+
repo.db.Exec(ctx, "INSERT INTO ...")
21+
}
22+
23+
func (repo *Repo) Update(ctx context.Context) error {
24+
repo.db.Exec(ctx, "UPDATE ... SET ...")
25+
}
26+
27+
func (repo *Repo) InsertAndUpdate(ctx context.Context) error {
28+
return repo.db.RunTx(ctx, func(ctx context.Context) error {
29+
repo.Insert()
30+
repo.Update()
31+
})
32+
}
33+
```

0 commit comments

Comments
 (0)