models

package
v0.0.0-...-6d0b726 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

models/plaid_integration.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PlaidIntegration

type PlaidIntegration struct {
	ID          uint32    `gorm:"primary_key;auto_increment" json:"id"`
	UserID      uint32    `gorm:"not null;index" json:"user_id"` // Add index for faster queries
	PlaidItemID string    `gorm:"not null" json:"plaid_item_id"`
	AccessToken string    `gorm:"not null" json:"access_token"`
	CreatedAt   time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt   time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

PlaidIntegration represents a user's linked bank account via Plaid.

func (*PlaidIntegration) Delete

func (i *PlaidIntegration) Delete(db *gorm.DB, id uint32) error

Delete removes a specific PlaidIntegration.

func (*PlaidIntegration) DeleteByUserID

func (i *PlaidIntegration) DeleteByUserID(db *gorm.DB, userID uint32) error

DeleteByUserID removes all PlaidIntegrations for a given UserID.

func (*PlaidIntegration) FindByID

func (i *PlaidIntegration) FindByID(db *gorm.DB, id uint32) (*PlaidIntegration, error)

FindByID retrieves a specific PlaidIntegration by its ID.

func (*PlaidIntegration) FindByUserID

func (i *PlaidIntegration) FindByUserID(db *gorm.DB, userID uint32) ([]PlaidIntegration, error)

FindByUserID retrieves all PlaidIntegrations for a user.

func (*PlaidIntegration) Prepare

func (i *PlaidIntegration) Prepare()

Prepare sanitizes input and initializes timestamps.

func (*PlaidIntegration) Save

func (i *PlaidIntegration) Save(db *gorm.DB) (*PlaidIntegration, error)

Save creates a new PlaidIntegration record.

func (*PlaidIntegration) Update

func (i *PlaidIntegration) Update(db *gorm.DB, updateData map[string]interface{}) (*PlaidIntegration, error)

Update updates an existing PlaidIntegration.

type ResetPassword

type ResetPassword struct {
	gorm.Model
	Email string `gorm:"size:100;not null;" json:"email"`
	Token string `gorm:"size:255;not null;" json:"token"`
}

func (*ResetPassword) DeleteDatails

func (resetPassword *ResetPassword) DeleteDatails(db *gorm.DB) (int64, error)

func (*ResetPassword) Prepare

func (resetPassword *ResetPassword) Prepare()

func (*ResetPassword) SaveDatails

func (resetPassword *ResetPassword) SaveDatails(db *gorm.DB) (*ResetPassword, error)

type User

type User struct {
	ID         uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Firstname  string    `gorm:"size:255;not null;" json:"firstname"`
	Lastname   string    `gorm:"size:255;not null;" json:"lastname"`
	Username   string    `gorm:"size:255;not null;unique_index" json:"username"` // Add unique index
	Email      string    `gorm:"size:100;not null;unique_index" json:"email"`    // Add unique index
	Password   string    `gorm:"size:100;not null;" json:"password"`             // Don't expose password in JSON responses
	AvatarPath string    `gorm:"size:255;null;" json:"avatar_path"`
	CreatedAt  time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt  time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

func (*User) AfterFind

func (u *User) AfterFind() (err error)

func (*User) BeforeSave

func (u *User) BeforeSave(tx *gorm.DB) (err error)

func (*User) DeleteAUser

func (u *User) DeleteAUser(db *gorm.DB, uid uint32) (int64, error)

func (*User) DeleteIntegrationsByUserID

func (u *User) DeleteIntegrationsByUserID(db *gorm.DB) error

DeleteIntegrationsByUserID deletes all PlaidIntegrations associated with a user ID.

func (*User) FindAllUsers

func (u *User) FindAllUsers(db *gorm.DB) (*[]User, error)

func (*User) FindUserByID

func (u *User) FindUserByID(db *gorm.DB, uid uint32) (*User, error)

func (*User) GetIntegrations

func (u *User) GetIntegrations(db *gorm.DB) ([]PlaidIntegration, error)

GetIntegrations retrieves all PlaidIntegrations associated with a user.

func (*User) Prepare

func (u *User) Prepare()

func (*User) SaveUser

func (u *User) SaveUser(db *gorm.DB) (*User, error)

func (*User) UpdateAUser

func (u *User) UpdateAUser(db *gorm.DB, uid uint32, updateData map[string]interface{}) (*User, error)

func (*User) UpdateAUserAvatar

func (u *User) UpdateAUserAvatar(db *gorm.DB, uid uint32) (*User, error)

func (*User) UpdatePassword

func (u *User) UpdatePassword(db *gorm.DB) error

func (*User) Validate

func (u *User) Validate(action string) map[string]string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL