queryComments( )
Creates a query to retrieve a list of comments.
Description
The queryComments()
function builds a query to retrieve a list of comments and returns a CommentsQueryBuilder
object.
The returned object contains the query definition, which is typically used to run the query using the find()
function.
You can refine the query by chaining CommentsQueryBuilder
functions onto the query. CommentsQueryBuilder
functions enable you to sort, filter, and control the results that queryComments()
returns.
queryComments()
runs with the following CommentsQueryBuilder
default that you can override:
ascending("_id")
The functions that are chained to queryComments()
are applied in the order they are called. For example, if you apply ascending("voteSummary.netVoteCount")
and then ascending("replyCount")
, the results are sorted first by the "voteSummary.netVoteCount"
, and then, if there are multiple results with the same "voteSummary.netVoteCount"
, the items are sorted by "replyCount"
.
The following CommentsQueryBuilder
functions are supported for the queryComments()
function. For a full description of the comment object, see the object returned for the items
property in CommentsQueryResult
.
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
_id | eq() ,ne() ,in() |
contextId | eq() ,ne() ,in() |
resourceId | eq() ,ne() ,in() |
author.userId | eq() ,ne() ,in() |
author.memberId | eq() ,ne() ,in() |
author.visitorId | eq() ,ne() ,in() |
parentComment.id | eq() ,ne() ,in() |
replyCount | eq() ,ne() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
voteSummary.netVoteCount | eq() ,ne() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
status | eq() ,ne() ,in() |
rating | eq() ,ne() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
reactionSummary.total | eq() ,ne() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
marked | eq() ,ne() ,ascending() ,descending() |
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function queryComments(appId: string): CommentsQueryBuilder
queryComments Parameters
NAME
TYPE
DESCRIPTION
App ID to query comments for.
Returns
Return Type:
Was this helpful?
queryComments example
1import { comments } from 'wix-comments.v2';23 async function queryComments() {4 const { items } = comments.queryComments().find();5 }6