postgres

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database is used to store metadata about a repository of media files.

func Open

func Open(dbProperties *config.DatabaseOptions) (*Database, error)

Open opens a postgres database.

func (*Database) GetMediaMetadata

func (d *Database) GetMediaMetadata(
	ctx context.Context, mediaID types.MediaID, mediaOrigin gomatrixserverlib.ServerName,
) (*types.MediaMetadata, error)

GetMediaMetadata returns metadata about media stored on this server. The media could have been uploaded to this server or fetched from another server and cached here. Returns nil metadata if there is no metadata associated with this media.

func (*Database) GetMediaMetadataByHash

func (d *Database) GetMediaMetadataByHash(
	ctx context.Context, mediaHash types.Base64Hash, mediaOrigin gomatrixserverlib.ServerName,
) (*types.MediaMetadata, error)

GetMediaMetadataByHash returns metadata about media stored on this server. The media could have been uploaded to this server or fetched from another server and cached here. Returns nil metadata if there is no metadata associated with this media.

func (*Database) GetThumbnail

func (d *Database) GetThumbnail(
	ctx context.Context,
	mediaID types.MediaID,
	mediaOrigin gomatrixserverlib.ServerName,
	width, height int,
	resizeMethod string,
) (*types.ThumbnailMetadata, error)

GetThumbnail returns metadata about a specific thumbnail. The media could have been uploaded to this server or fetched from another server and cached here. Returns nil metadata if there is no metadata associated with this thumbnail.

func (*Database) GetThumbnails

func (d *Database) GetThumbnails(
	ctx context.Context, mediaID types.MediaID, mediaOrigin gomatrixserverlib.ServerName,
) ([]*types.ThumbnailMetadata, error)

GetThumbnails returns metadata about all thumbnails for a specific media stored on this server. The media could have been uploaded to this server or fetched from another server and cached here. Returns nil metadata if there are no thumbnails associated with this media.

func (*Database) StoreMediaMetadata

func (d *Database) StoreMediaMetadata(
	ctx context.Context, mediaMetadata *types.MediaMetadata,
) error

StoreMediaMetadata inserts the metadata about the uploaded media into the database. Returns an error if the combination of MediaID and Origin are not unique in the table.

func (*Database) StoreThumbnail

func (d *Database) StoreThumbnail(
	ctx context.Context, thumbnailMetadata *types.ThumbnailMetadata,
) error

StoreThumbnail inserts the metadata about the thumbnail into the database. Returns an error if the combination of MediaID and Origin are not unique in the table.

Jump to

Keyboard shortcuts

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