Query Posts
The social.plus SDK provides powerful post querying functionality that enables flexible content discovery and filtering. Query posts from communities, user feeds, or across the entire platform with customizable search criteria and real-time results.Overview
Flexible Filtering
Filter by post type, target, deletion status, and custom criteria
Live Results
Query results are returned as live collections with real-time updates
Query Parameters
Parameter | Type | Description | Options |
---|---|---|---|
targetId | String | Community or user ID | Community ID, User ID |
targetType | String | Type of target | community , user |
types | Array | Post content types | text , image , video , file , poll , liveStream , custom |
includeDeleted | Boolean | Include deleted posts | true , false (default) |
sortBy | String | Sort order | lastCreated (default), firstCreated |
feedType | String | Feed type filter | published , reviewing , declined |
Basic Post Querying
Advanced Query Features
Content Type Filtering
Content Type Filtering
Filter posts by specific content types to create focused views:
- Media Gallery: Query only image and video posts
- Text Content: Retrieve text-only posts for text analysis
- File Sharing: Focus on file attachment posts
- Interactive Content: Filter polls and live streams
Deletion Status Management
Deletion Status Management
Control visibility of deleted content based on user permissions:
- Standard Users: See only their own deleted posts
- Moderators: View all soft-deleted posts in communities
- Admins: Access complete deletion history
- Audit Trails: Track content lifecycle for compliance
Feed Types for Moderation
Feed Types for Moderation
Query posts based on their review status:
- Published: Live posts visible to all users
- Reviewing: Posts pending moderation approval
- Declined: Posts rejected by moderators
- Mixed: Custom combinations for workflow management
Performance Optimization
Performance Optimization
Optimize query performance for large datasets:
- Pagination: Load posts in manageable chunks
- Lazy Loading: Fetch additional data on demand
- Caching: Store frequently accessed queries
- Indexing: Leverage server-side optimizations
Common Use Cases
Community Feed
Display all posts in a community with real-time updates and customizable filtering options.
User Profile
Show a user’s post history with privacy controls and content type filtering.
Media Gallery
Create image and video galleries by filtering posts with media attachments.
Content Moderation
Review pending posts and manage community content with moderation-specific queries.
Analytics Dashboard
Gather post data for engagement metrics and community insights.
Search Results
Implement advanced search functionality with multiple filter criteria.
Best Practices
Query Optimization
Query Optimization
- Use specific post types instead of querying all types
- Implement pagination for large result sets
- Cache frequently accessed queries
- Dispose of live collections when no longer needed
User Experience
User Experience
- Show loading states during query execution
- Implement pull-to-refresh for live collections
- Provide empty states for no results
- Use skeleton screens for better perceived performance
Error Handling
Error Handling
- Handle network connectivity issues gracefully
- Implement retry mechanisms for failed queries
- Provide meaningful error messages to users
- Log query errors for debugging purposes
Memory Management
Memory Management
- Dispose of live collections when views are destroyed
- Implement proper lifecycle management
- Use weak references to prevent memory leaks
- Monitor memory usage in production
Query Examples
Custom Post Types: For custom post types, use a namespace-like format (e.g.,
"my.customtype"
). This ensures proper categorization and prevents conflicts with built-in types.Performance Note: Querying large datasets without proper filtering can impact performance. Always use appropriate filters and pagination for optimal user experience.