Documentation ¶
Index ¶
- func Delete(client *mongo.Client, ctx context.Context, database string, session *Session) (int64, error)
- func DeleteByID(client *mongo.Client, ctx context.Context, database string, ...) (int64, error)
- func DeleteByToken(client *mongo.Client, ctx context.Context, database string, ...) (int64, error)
- func Insert(client *mongo.Client, ctx context.Context, database string, session *Session) error
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(client *mongo.Client, ctx context.Context, database string, session *Session) (int64, error)
This function deletes the session given in the function parameters.
It returns the count of deleted sessions, which can be either 0 or 1, or an error when something went wrong while deleting the database entry.
func DeleteByID ¶
func DeleteByID(client *mongo.Client, ctx context.Context, database string, sessionID primitive.ObjectID) (int64, error)
This function searches the database for a session with the specified ID and deletes it.
It returns the count of deleted sessions, which can be either 0 or 1, or an error when something went wrong while deleting the database entry.
func DeleteByToken ¶
func DeleteByToken(client *mongo.Client, ctx context.Context, database string, sessionToken string) (int64, error)
This function searches the database for a session with the specified token and deletes it.
It returns the count of deleted sessions, which can be either 0 or 1, or an error when something went wrong while deleting the database entry.
Types ¶
type Session ¶
type Session struct { ID primitive.ObjectID `bson:"_id"` CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updated_at"` ExpiresAt time.Time `bson:"expires_at"` // The token used for identifying the session outside of the database. SessionToken string `bson:"session_token"` // The account whom this session belongs to. AccountID primitive.ObjectID `bson:"account_id"` }
This type represents a session saved in the database.
func FindByID ¶
func FindByID(client *mongo.Client, ctx context.Context, database string, ID primitive.ObjectID) (*Session, error)
This function searches the database for a session with the given ID and returns it if it was found. If no match was found, returns an error.
func FindByToken ¶
func FindByToken(client *mongo.Client, ctx context.Context, database string, token string) (*Session, error)
This function searches the database for a session with the given token and returns it if it was found. If no match was found, returns an error.
func (*Session) Delete ¶
func (session *Session) Delete(client *mongo.Client, ctx context.Context, database string) (int64, error)
This function deletes the session it is called upon.
It returns the count of deleted sessions, which can be either 0 or 1, or an error when something went wrong while deleting the database entry.