list.go (2906B)
1 // GoToSocial 2 // Copyright (C) GoToSocial Authors admin@gotosocial.org 3 // SPDX-License-Identifier: AGPL-3.0-or-later 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package db 19 20 import ( 21 "context" 22 23 "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" 24 ) 25 26 type List interface { 27 // GetListByID gets one list with the given id. 28 GetListByID(ctx context.Context, id string) (*gtsmodel.List, error) 29 30 // GetListsForAccountID gets all lists owned by the given accountID. 31 GetListsForAccountID(ctx context.Context, accountID string) ([]*gtsmodel.List, error) 32 33 // PopulateList ensures that the list's struct fields are populated. 34 PopulateList(ctx context.Context, list *gtsmodel.List) error 35 36 // PutList puts a new list in the database. 37 PutList(ctx context.Context, list *gtsmodel.List) error 38 39 // UpdateList updates the given list. 40 // Columns is optional, if not specified all will be updated. 41 UpdateList(ctx context.Context, list *gtsmodel.List, columns ...string) error 42 43 // DeleteListByID deletes one list with the given ID. 44 DeleteListByID(ctx context.Context, id string) error 45 46 // GetListEntryByID gets one list entry with the given ID. 47 GetListEntryByID(ctx context.Context, id string) (*gtsmodel.ListEntry, error) 48 49 // GetListEntries gets list entries from the given listID, using the given parameters. 50 GetListEntries(ctx context.Context, listID string, maxID string, sinceID string, minID string, limit int) ([]*gtsmodel.ListEntry, error) 51 52 // GetListEntriesForFollowID returns all listEntries that pertain to the given followID. 53 GetListEntriesForFollowID(ctx context.Context, followID string) ([]*gtsmodel.ListEntry, error) 54 55 // PopulateListEntry ensures that the listEntry's struct fields are populated. 56 PopulateListEntry(ctx context.Context, listEntry *gtsmodel.ListEntry) error 57 58 // PutListEntries inserts a slice of listEntries into the database. 59 // It uses a transaction to ensure no partial updates. 60 PutListEntries(ctx context.Context, listEntries []*gtsmodel.ListEntry) error 61 62 // DeleteListEntry deletes one list entry with the given id. 63 DeleteListEntry(ctx context.Context, id string) error 64 65 // DeleteListEntryForFollowID deletes all list entries with the given followID. 66 DeleteListEntriesForFollowID(ctx context.Context, followID string) error 67 }