use sui::table;

Explore this module further in the Mover Registry: @sage/shared

Structs

Favorite

Data on relationship created between a User and the content they want to favorite.

public struct Favorite has store

Favorites

All of the relationships that exist between Users and the content they have favorited.

public struct Favorites has store

Constants

Error code when attempting to favorite content that has already been favorited.

const EAlreadyFavorited: u64 = 370;

Error code when attempting to unfavorite content that has not been favorited.

const EIsNotFavorite: u64 = 371;

Functions

add

Favorite the content.

public fun add(favorites: &mut Favorites, key: address, timestamp: u64): u64

assert_has_not_favorited

Aborts with EAlreadyFavorited if the content has already been favorited.

public fun assert_has_not_favorited(favorites: &Favorites, key: address)

create

Creates a new instance of Favorites.

public fun create(ctx: &mut TxContext): Favorites

get_count

Gets the number of times the content has been favorited.

public fun get_count(favorites: &Favorites, key: address): u64

get_created_at

Get timestamp of when the content was first favorited.

public fun get_created_at(favorites: &Favorites, key: address): u64

get_length

Get the number of favorites on the content currently.

public fun get_length(favorites: &Favorites): u64

get_updated_at

Get timestamp of when the content was most recently favorited.

public fun get_updated_at(favorites: &Favorites, key: address): u64

is_favorite

Returns true or false based on whether the content has currently been favorited.

public fun is_favorite(favorites: &Favorites, key: address): bool

remove

Unfavorite the content.

public fun remove(favorites: &mut Favorites, key: address, timestamp: u64): u64