Skip to main content

Posts With Details

All entities (posts, profiles, and spaces) are interconnected. For faster data retrieval use the findPostWithAllDetails method.

Find and load a single post#

findPostWithAllDetails#

Finds and loads a post with their extension and the owner's profile and space (if defined).

flatApi.findPostWithAllDetails(id: AnyPostId): Promise<PostWithAllDetails | undefined>

Example:

flatApi.findPostWithAllDetails('1')

Output:

{
"ext": undefined,
"id": "1",
"post": {"id": "1"...},
"owner": {"id": "3osmnRNnrcScHsgkTJH1xyBF5kGjpbWHsGrqM31BJpy4vwn8"...},
"space": {"id": "1"...}
}

๐Ÿ†ƒ AnyPostId: PostId | BN

๐Ÿ†ƒ PostWithAllDetails: PostWithOwner & PostWithSpace

findPostWithSomeDetails#

Finds and loads a post with their extension and the owner's profile (if defined).

flatApi.findPostWithSomeDetails(query: FindPostWithDetailsQuery): Promise<PostWithSomeDetails | undefined>
PropertiesDescription
idsAn array of IDs of desired structs.
visibilityFilter for the visible state of the structs (see Visibility)
withContentOnly?Boolean.
withSpace?Pass true to get the space data.
withOwner?Pass true to get the profile data.

๐Ÿ†ƒ Visibility: 'onlyVisible' | 'onlyHidden' | 'onlyPublic' | 'onlyUnlisted'

The four visible state filters correspond to the next conditions:

FiltersDescription
onlyVisiblereturns posts where the hidden field on the corresponding Substrate struct is false.
onlyHiddenreturns posts where the hidden field on the corresponding Substrate struct is true.
onlyPublicreturns posts where the hidden field on the corresponding Substrate struct is false and there is a corresponding JSON file on IPFS.
onlyUnlistedreturns posts where either the hidden field is true or there is no corresponding JSON file on IPFS.

Example:

flatApi.findPostWithSomeDetails({id: '1'})

Output:

{
"ext": undefined,
"id": "1",
"post": {"id": "1"...},
"owner": undefined,
"space": undefined
}

Example with owner:

flatApi.findPostWithSomeDetails({id: '1', withOwner: true})

Output:

{
"ext": undefined,
"id": "1",
"post": {"id": "1"...},
"owner": {"id": "3osmnRNnrcScHsgkTJH1xyBF5kGjpbWHsGrqM31BJpy4vwn8"...},
"space": undefined
}

๐Ÿ†ƒ PostWithSomeDetails: { ext?: Exclude<PostWithSomeDetails, "ext">; owner?: ProfileData; post: PostData; space?: SpaceData }

๐Ÿ†ƒ FindPostWithDetailsQuery: FindPostQuery & PostDetailsOpts

Find and load an array of posts#

findPostsWithAllDetails#

findPostsWithAllDetails returns information of the post, space and owner (profile).

flatApi.findPostsWithAllDetails(query: FindPostsQuery): Promise<PostWithAllDetails[]>
PropertiesDescription
idsAn array of IDs of desired structs.
visibilityFilter for the visible state of the structs (see Visibility)
withContentOnly?Boolean.

๐Ÿ†ƒ FindPostsQuery: FindStructs < AnyPostId >

๐Ÿ†ƒ PostWithAllDetails: PostWithOwner & PostWithSpace

๐Ÿ‘‡ There are also methods with ready-made visibility filters.

findPublicPostsWithAllDetails#

Find and load posts that have the hidden == false field in their Substrate struct and their IPFS content is not empty, using their extension and the owner's profile and space (if defined).

flatApi.findPublicPostsWithAllDetails(ids: AnyPostId[]): Promise<PostWithAllDetails[]>

๐Ÿ†ƒ PostWithAllDetails: PostWithOwner & PostWithSpace

๐Ÿ†ƒ AnyPostId: PostId | BN

findUnlistedPostsWithAllDetails#

Find and load posts that have the hidden == true field in their Substrate struct and their IPFS content is not empty, using their extension and owner's profile and space (if defined).

flatApi.findUnlistedPostsWithAllDetails(ids: AnyPostId[]): Promise<PostWithAllDetails[]>

๐Ÿ†ƒ PostWithAllDetails: PostWithOwner & PostWithSpace

๐Ÿ†ƒ AnyPostId: PostId | BN

findPublicPostsWithSomeDetails#

Load an array of information about public posts with the space and/or owner.

flatApi.findPublicPostsWithSomeDetails(query: FindPostsWithDetailsQuery): Promise<PostWithSomeDetails[]
PropertiesDescription
idsAn array of IDs of desired structs.
visibilityFilter for the visible state of the structs (see Visibility)
withContentOnly?Boolean.
withSpace?Pass true to get the space data.
withOwner?Pass true to get the profile data.

๐Ÿ†ƒ FindPostsWithDetailsQuery: FindPostsQuery & PostDetailsOpts

๐Ÿ†ƒ PostWithSomeDetails: { ext?: Exclude<PostWithSomeDetails, "ext">; owner?: ProfileData; post: PostData; space?: SpaceData }