Adapter is the interface that must be implemented by a database adapter. The current schema supports a single connection by database type.
| 12 | // Adapter is the interface that must be implemented by a database |
| 13 | // adapter. The current schema supports a single connection by database type. |
| 14 | type Adapter interface { |
| 15 | // General |
| 16 | |
| 17 | // Open and configure the adapter |
| 18 | Open(config json.RawMessage) error |
| 19 | // Close the adapter |
| 20 | Close() error |
| 21 | // IsOpen checks if the adapter is ready for use |
| 22 | IsOpen() bool |
| 23 | // GetDbVersion returns current database version. |
| 24 | GetDbVersion() (int, error) |
| 25 | // CheckDbVersion checks if the actual database version matches adapter version. |
| 26 | CheckDbVersion() error |
| 27 | // GetName returns the name of the adapter |
| 28 | GetName() string |
| 29 | // SetMaxResults configures how many results can be returned in a single DB call. |
| 30 | SetMaxResults(val int) error |
| 31 | // CreateDb creates the database optionally dropping an existing database first. |
| 32 | CreateDb(reset bool) error |
| 33 | // UpgradeDb upgrades database to the current adapter version. |
| 34 | UpgradeDb() error |
| 35 | // Version returns adapter version |
| 36 | Version() int |
| 37 | // DB connection stats object. |
| 38 | Stats() any |
| 39 | |
| 40 | // User management |
| 41 | |
| 42 | // UserCreate creates user record |
| 43 | UserCreate(user *t.User) error |
| 44 | // UserGet returns record for a given user ID |
| 45 | UserGet(uid t.Uid) (*t.User, error) |
| 46 | // UserGetAll returns user records for a given list of user IDs |
| 47 | UserGetAll(ids ...t.Uid) ([]t.User, error) |
| 48 | // UserDelete deletes user record |
| 49 | UserDelete(uid t.Uid, hard bool) error |
| 50 | // UserUpdate updates user record |
| 51 | UserUpdate(uid t.Uid, update map[string]any) error |
| 52 | // UserUpdateTags adds, removes, or resets user's tags |
| 53 | UserUpdateTags(uid t.Uid, add, remove, reset []string) ([]string, error) |
| 54 | // UserGetByCred returns user ID for the given validated credential. |
| 55 | UserGetByCred(method, value string) (t.Uid, error) |
| 56 | // UserUnreadCount returns the total number of unread messages in all topics with |
| 57 | // the R permission. If read fails, the counts are still returned with the original |
| 58 | // user IDs but with the unread count undefined and non-nil error. |
| 59 | UserUnreadCount(ids ...t.Uid) (map[t.Uid]int, error) |
| 60 | // UserGetUnvalidated returns a list of no more than 'limit' uids who never logged in, |
| 61 | // have no validated credentials and which haven't been updated since 'lastUpdatedBefore'. |
| 62 | UserGetUnvalidated(lastUpdatedBefore time.Time, limit int) ([]t.Uid, error) |
| 63 | |
| 64 | // Credential management |
| 65 | |
| 66 | // CredUpsert adds or updates a credential record. Returns true if record was inserted, false if updated. |
| 67 | CredUpsert(cred *t.Credential) (bool, error) |
| 68 | // CredGetActive returns the currently active credential record for the given method. |
| 69 | CredGetActive(uid t.Uid, method string) (*t.Credential, error) |
| 70 | // CredGetAll returns credential records for the given user and method, validated only or all. |
| 71 | CredGetAll(uid t.Uid, method string, validatedOnly bool) ([]t.Credential, error) |
no outgoing calls
no test coverage detected
searching dependent graphs…