diff options
author | Alexander NeonXP Kiryukhin <i@neonxp.ru> | 2024-07-21 19:26:56 +0300 |
---|---|---|
committer | Alexander NeonXP Kiryukhin <i@neonxp.ru> | 2024-07-21 19:28:56 +0300 |
commit | ce3111b0efe91e275ce070f9511b5b1b9801a46d (patch) | |
tree | 09fa4f10dfb1e17761339c798eefa73c6b18484f /repository/node.go | |
parent | e9a64f3b41b5eae47dec7c0ecfd1caae83136abc (diff) |
Множество улучшенийv0.0.2
Diffstat (limited to 'repository/node.go')
-rw-r--r-- | repository/node.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/repository/node.go b/repository/node.go index d5794b6..27282af 100644 --- a/repository/node.go +++ b/repository/node.go @@ -42,17 +42,17 @@ func (t *Node) Get(ctx context.Context, topicID int) (*models.Node, error) { Model(node). Where(`n.id = ?`, topicID). Relation("Author"). + Relation("Parent"). Scan(ctx) } -func (t *Node) List(ctx context.Context, topicID int) ([]*models.Node, int, error) { +func (t *Node) List(ctx context.Context, topicID int) ([]*models.Node, error) { posts := make([]*models.Node, 0) - count, err := t.db.NewSelect(). + return posts, t.db.NewSelect(). Model(&posts). Where(`parent_id = ?`, topicID). Relation("Author"). - ScanAndCount(ctx) - - return posts, count, err + Relation("Children"). + Scan(ctx) } |