db.go (2048B)
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 const ( 27 // DBTypePostgres represents an underlying POSTGRES database type. 28 DBTypePostgres string = "POSTGRES" 29 ) 30 31 // DB provides methods for interacting with an underlying database or other storage mechanism. 32 type DB interface { 33 Account 34 Admin 35 Basic 36 Domain 37 Emoji 38 Instance 39 List 40 Media 41 Mention 42 Notification 43 Relationship 44 Report 45 Search 46 Session 47 Status 48 StatusBookmark 49 StatusFave 50 Timeline 51 User 52 Tombstone 53 54 /* 55 USEFUL CONVERSION FUNCTIONS 56 */ 57 58 // TagStringToTag takes a lowercase tag in the form "somehashtag", which has been 59 // used in a status. It takes the id of the account that wrote the status, and the id of the status itself, and then 60 // returns an *apimodel.Tag corresponding to the given tags. If the tag already exists in database, that tag 61 // will be returned. Otherwise a pointer to a new tag struct will be created and returned. 62 // 63 // Note: this func doesn't/shouldn't do any manipulation of tags in the DB, it's just for checking 64 // if they exist in the db already, and conveniently returning them, or creating new tag structs. 65 TagStringToTag(ctx context.Context, tag string, originAccountID string) (*gtsmodel.Tag, error) 66 }