feat(sources): get all source nodes
Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
parent
c1df01d113
commit
ebc7fcc571
25
internal/postgres/source.go
Normal file
25
internal/postgres/source.go
Normal file
@ -0,0 +1,25 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// GetAllSourceNodes returns a list of all models.AnthroveSource
|
||||
func GetAllSourceNodes(ctx context.Context, db *gorm.DB) ([]models.AnthroveSource, error) {
|
||||
var sources []models.AnthroveSource
|
||||
|
||||
result := db.WithContext(ctx).Find(&sources)
|
||||
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"tag_amount": result.RowsAffected,
|
||||
}).Trace("database: get all source nodes")
|
||||
|
||||
return sources, nil
|
||||
}
|
Reference in New Issue
Block a user