Posts Query

Overview

Posts Query API is capable of the following items:

  • Search all posts on the server that match the criteria

  • Scoped searching

  • Post types filtering

  • Deleted or non-deleted state filtering

  • Results ordering

Search and Results Behavior

Posts Query API searches all the posts in the database. Any posts that match the criteria will be put into the live collection, regardless of whether it is a parent or a child post.

Posts Query API returns a live collection, with the flattened post objects. The collection can contain parent and child posts, ordered by the sorting criteria.

Use-cases

Posts Query API can be useful for the use-cases that require flattening the search and results. For example:

  • Media gallery that shows the list of all images, posted by a user

  • List of all the text posts that are deleted in a community

Usage

The supported query post types are video, image, file, liveStream , poll and custom post.

For custom post, follow a namespace like format. Example: "upstra.customtype"

Post Query Caching

Caching, in general, aims to increase data retrieval performance by saving the data in cache memory and retrieving it from cache upon loading or refreshing the app. This mechanism enables faster load and response times which helps improve efficiency and performance of the application.

We support caching for the following data:

  • Users

  • Comments

  • Messages

  • Posts

During post query, the application will load the data from cache if it is still valid without fetching from the server.

How does caching work?

When a user loads the application or refreshes the browser, the app will do an internal query and retrieve the cached data. However, it will check the freshness of the data first to determine if it is still valid. If the data has been fetched before and has not expired, the query will acquire the data from the cache without fetching from the server. If the data has expired, however, the app will query the server to get fresh data.

By default, data is considered valid if it is residing in the cache memory for not more than 120,000 ms (two minutes). You can change the global modelDataLifespan field in SDK config or override the modelDataLifespan field for specific models in your code to change the duration limit that will determine the validity of the data in cache.

How is caching implemented?

Caching is based on using stores inside SDK. Each store contains data collections. For each new request, we call loadNextData function and load new data from back end.

Last updated