Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(client *mongo.Client, ctx context.Context, database string, apiKey *ApiKey) (int64, error)
This function deletes the account given in the function parameters.
It returns the count of deleted api keys, which can be either 0 or 1, or an error when something went wrong while deleting the database entry.
Types ¶
type ApiKey ¶
type ApiKey struct {
ID primitive.ObjectID `bson:"_id"`
CreatedAt time.Time `bson:"created_at"`
UpdatedAt time.Time `bson:"updated_at"`
ExpiresAt time.Time `bson:"expires_at"`
Key string `bson:"key"`
Namespace string `bson:"namespace"`
AccessibleCollections []string `bson:"accessible_collections"`
CanRead bool `bson:"can_read"`
CanWrite bool `bson:"can_write"`
}
This type represents an api key in the database
func FindByID ¶
func FindByID(client *mongo.Client, ctx context.Context, database string, ID primitive.ObjectID) (*ApiKey, error)
This function searches the database for an api key with the given ID and returns it if it was found. If no match was found, returns an error.
func FindByKey ¶
func FindByKey(client *mongo.Client, ctx context.Context, database string, key string) (*ApiKey, error)
This function searches the database for an api key with the given key and returns it if it was found. If no match was found, returns an error.
func (*ApiKey) Delete ¶
func (apiKey *ApiKey) Delete(client *mongo.Client, ctx context.Context, database string) (int64, error)
This function deletes the api key it is called upon.
It returns the count of deleted api keys, which can be either 0 or 1, or an error when something went wrong while deleting the database entry.