Skip to content

Commit 551bde0

Browse files
committed
feat: git credential operations added
1 parent fb9f690 commit 551bde0

File tree

5 files changed

+504
-25
lines changed

5 files changed

+504
-25
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package core
2+
3+
import (
4+
"context"
5+
"gorm.io/gorm"
6+
)
7+
8+
// This file contains the operations for the GitCredential model.
9+
// This functions will perform necessary validation before doing the actual database operation.
10+
11+
// Each function's argument format should be (ctx context.Context, db gorm.DB, ...)
12+
// context used to pass some data to the function e.g. user id, auth info, etc.
13+
14+
func FindAllGitCredentials(ctx context.Context, db gorm.DB) ([]*GitCredential, error) {
15+
var gitCredentials []*GitCredential
16+
tx := db.Find(&gitCredentials)
17+
return gitCredentials, tx.Error
18+
}
19+
20+
func (gitCredential *GitCredential) FindById(ctx context.Context, db gorm.DB, id int) error {
21+
tx := db.First(gitCredential, id)
22+
return tx.Error
23+
}
24+
25+
func (gitCredential *GitCredential) Create(ctx context.Context, db gorm.DB) error {
26+
tx := db.Create(gitCredential)
27+
return tx.Error
28+
}
29+
30+
func (gitCredential *GitCredential) Update(ctx context.Context, db gorm.DB) error {
31+
tx := db.Save(gitCredential)
32+
return tx.Error
33+
}
34+
35+
func (gitCredential *GitCredential) Delete(ctx context.Context, db gorm.DB) error {
36+
tx := db.Delete(gitCredential)
37+
return tx.Error
38+
}

0 commit comments

Comments
 (0)