// Copyright 2022 The Gogs Authors. All rights reserved.// Use of this source code is governed by a MIT-style// license that can be found in the LICENSE file.packagedbimport("context""gorm.io/gorm")// OrgUsersStore is the persistent interface for organization-user relations.//// NOTE: All methods are sorted in alphabetical order.typeOrgUsersStoreinterface{// CountByUser returns the number of organizations the user is a member of.CountByUser(ctxcontext.Context,userIDint64)(int64,error)}varOrgUsersOrgUsersStorevar_OrgUsersStore=(*orgUsers)(nil)typeorgUsersstruct{*gorm.DB}// NewOrgUsersStore returns a persistent interface for organization-user// relations with given database connection.funcNewOrgUsersStore(db*gorm.DB)OrgUsersStore{return&orgUsers{DB:db}}func(db*orgUsers)CountByUser(ctxcontext.Context,userIDint64)(int64,error){varcountint64returncount,db.WithContext(ctx).Model(&OrgUser{}).Where("uid = ?",userID).Count(&count).Error}