> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sageprotocol.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Posts

> Stores and manages collections of post addresses associated with an entity.

```rust theme={null}
use sui::table;
```

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

## Structs

### `Posts`

A collection of `Post` structs.

```rust theme={null}
public struct Posts has store
```

<Expandable title="Fields">
  ```rust theme={null}
    posts: sui::table::Table<u64, address>
  ```
</Expandable>

## Functions

### `add`

Add a `Post` to the collection.

```rust theme={null}
public fun add(posts: &mut Posts, post_timestamp: u64, post_address: address)
```

<Expandable title="Implementation">
  ```rust theme={null}
    public fun add(
        posts: &mut Posts,
        post_timestamp: u64,
        post_address: address
    ) {
        posts.posts.add(
            post_timestamp, 
            post_address
        );
    }
  ```
</Expandable>

### `create`

Create a new `Posts` instance.

```rust theme={null}
public fun create(ctx: &mut TxContext): Posts
```

<Expandable title="Implementation">
  ```rust theme={null}
    public fun create(
        ctx: &mut TxContext
    ): Posts {
        Posts {
            posts: table::new(ctx)
        }
    }
  ```
</Expandable>

### `get_length`

Get the total number of `Post`s in the collection.

```rust theme={null}
public fun get_length(posts: &Posts): u64
```

<Expandable title="Implementation">
  ```rust theme={null}
    public fun get_length(
        posts: &Posts
    ): u64 {
        posts.posts.length()
    }
  ```
</Expandable>

### `has_record`

Returns true or false based on whether a `Post` exists at a timestamp.

```rust theme={null}
public fun has_record(posts: &Posts, post_timestamp: u64): bool
```

<Expandable title="Implementation">
  ```rust theme={null}
    public fun has_record(
        posts: &Posts,
        post_timestamp: u64
    ): bool {
        posts.posts.contains(post_timestamp)
    }
  ```
</Expandable>
