Documentation ¶
Index ¶
- type App
- func (a *App) BatchInsert(ctx context.Context, db *gorm.DB, apps []App) error
- func (a *App) Count(ctx context.Context, db *gorm.DB) (int64, error)
- func (a *App) CountByArgs(ctx context.Context, db *gorm.DB, query interface{}, args ...interface{}) (int64, error)
- func (a *App) Create(ctx context.Context, db *gorm.DB) (uint, error)
- func (a *App) Delete(ctx context.Context, db *gorm.DB) error
- func (a *App) FindWithPagination(ctx context.Context, db *gorm.DB, page, size int) ([]App, error)
- func (a *App) FindWithSort(ctx context.Context, db *gorm.DB, sort string) ([]App, error)
- func (a *App) First(ctx context.Context, db *gorm.DB) (*App, error)
- func (a *App) Last(ctx context.Context, db *gorm.DB) (*App, error)
- func (a *App) List(ctx context.Context, db *gorm.DB) ([]App, error)
- func (a *App) ListByArgs(ctx context.Context, db *gorm.DB, query interface{}, args ...interface{}) ([]App, error)
- func (a *App) TableName() string
- func (a *App) Updates(ctx context.Context, db *gorm.DB, updates map[string]interface{}) error
- type MgoApp
- func (a *MgoApp) CollectionName() string
- func (a *MgoApp) Count(ctx context.Context, db *qmgo.Database) (int64, error)
- func (a *MgoApp) Create(ctx context.Context, db *qmgo.Database) (string, error)
- func (a *MgoApp) Creates(ctx context.Context, db *qmgo.Database, apps []MgoApp) ([]primitive.ObjectID, error)
- func (a *MgoApp) Delete(ctx context.Context, db *qmgo.Database) error
- func (a *MgoApp) FindWithSort(ctx context.Context, db *qmgo.Database, sort string) ([]MgoApp, error)
- func (a *MgoApp) First(ctx context.Context, db *qmgo.Database) (*MgoApp, error)
- func (a *MgoApp) Last(ctx context.Context, db *qmgo.Database) (*MgoApp, error)
- func (a *MgoApp) List(ctx context.Context, db *qmgo.Database) ([]MgoApp, error)
- func (a *MgoApp) Pagination(ctx context.Context, db *qmgo.Database, page, size int) ([]MgoApp, error)
- func (a *MgoApp) Updates(ctx context.Context, db *qmgo.Database, updates bson.M) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { gorm.Model AppID string `gorm:"column:app_id" json:"app_id"` // Application ID AppName string `gorm:"column:app_name" json:"app_name"` // Application Name AppSecret string `gorm:"column:app_secret" json:"app_secret"` // Application Secret Key RedirectUri string `gorm:"column:redirect_uri" json:"redirect_uri"` // Redirect URI after authorization Description string `gorm:"column:description" json:"description"` // Description Status int8 `gorm:"column:status" json:"status"` // 1: Active; 2: Disabled }
func (*App) BatchInsert ¶ added in v1.4.0
BatchInsert inserts multiple apps into the database in a single batch operation.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - apps: slice of App instances to be inserted.
Returns: - error: error if the batch insert operation fails, otherwise nil.
func (*App) Count ¶ added in v1.4.0
Count counts the number of apps matching the criteria in the database.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.
Returns: - int64: count of matching apps. - error: error if the count operation fails, otherwise nil.
func (*App) CountByArgs ¶ added in v1.4.0
func (a *App) CountByArgs(ctx context.Context, db *gorm.DB, query interface{}, args ...interface{}) (int64, error)
CountByArgs counts the number of apps matching the specified query and arguments in the database.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - query: SQL query string. - args: variadic arguments for the SQL query.
Returns: - int64: count of matching apps. - error: error if the count operation fails, otherwise nil.
func (*App) Create ¶
Create inserts a new app into the database and returns the ID of the created App.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.
Returns: - uint: ID of the created app. - error: error if the insert operation fails, otherwise nil.
func (*App) Delete ¶
Delete removes the app from the database.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.
Returns: - error: error if the delete operation fails, otherwise nil.
func (*App) FindWithPagination ¶ added in v1.4.0
FindWithPagination retrieves apps matching the criteria from the database with pagination support.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - page: page number for pagination (1-based). - size: number of apps per page.
Returns: - []App: slice of retrieved apps. - error: error if the query fails, otherwise nil.
func (*App) FindWithSort ¶ added in v1.4.0
FindWithSort retrieves apps matching the criteria from the database with sorting support.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - sort: sorting criteria (e.g., "id desc").
Returns: - []App: slice of retrieved apps. - error: error if the query fails, otherwise nil.
func (*App) First ¶
First retrieves the first app matching the criteria from the database.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.
Returns: - *App: pointer to the retrieved app, or nil if not found. - error: error if the query fails, otherwise nil.
func (*App) Last ¶ added in v1.4.0
Last retrieves the last app matching the criteria from the database, ordered by ID in descending order.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.
Returns: - *App: pointer to the retrieved app, or nil if not found. - error: error if the query fails, otherwise nil.
func (*App) List ¶ added in v1.4.0
List retrieves all apps matching the criteria from the database.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.
Returns: - []App: slice of retrieved apps. - error: error if the query fails, otherwise nil.
func (*App) ListByArgs ¶ added in v1.4.0
func (a *App) ListByArgs(ctx context.Context, db *gorm.DB, query interface{}, args ...interface{}) ([]App, error)
ListByArgs retrieves apps matching the specified query and arguments from the database, ordered by ID in descending order.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - query: SQL query string. - args: variadic arguments for the SQL query.
Returns: - []App: slice of retrieved apps. - error: error if the query fails, otherwise nil.
func (*App) Updates ¶
Updates applies the specified updates to the app in the database.
Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - updates: map[string]interface{} containing the updates to apply.
Returns: - error: error if the update operation fails, otherwise nil.
type MgoApp ¶ added in v1.4.0
type MgoApp struct { ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` AppName string `bson:"app_name" json:"app_name"` AppID string `bson:"app_id" json:"app_id"` AppSecret string `bson:"app_secret" json:"app_secret"` RedirectUri string `bson:"redirect_uri" json:"redirect_uri"` Description string `bson:"description" json:"description"` Status uint8 `bson:"status" json:"status"` }