queryTags( )


Creates a query to retrieve a list of tags.

The queryTags() function builds a query to retrieve a list of up to 4,000 tags per language, and returns a TagsQueryBuilder 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 TagsQueryBuilder functions onto the query. TagsQueryBuilder functions enable you to sort, filter, and control the results that queryTags() returns.

queryTags() runs with these TagsQueryBuilder defaults that can be overridden:

The following TagQueryBuilder functions are supported for queryTags(). For a full description of the Tags object, see the object returned for the items property in TagsQueryResult.

PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),hasSome()
labeleq(),ne(),startsWith(),hasSome(),exists(),in(),ascending(),descending()
slugeq(),ne(),startsWith(),hasSome(),exists(),in(),ascending(),descending()
publicationCounteq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
postCounteq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
translationIdeq(),ne(),exists(),in()
languageeq(),ne(),exists(),in(),ascending(),descending()
Permissions
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about app permissions.
Method Declaration
Copy
function queryTags(options: QueryTagsOptions): TagsQueryBuilder;
Method Parameters
optionsQueryTagsOptions

Options specifying which fields to return.

Returns
Return Type:TagsQueryBuilder

This example uses the queryTags() function to retrieve all tags.

JavaScript
import { tags } from "wix-blog-backend"; export async function queryTagsFunction() { try { const queryTagsResults = await tags.queryTags().find(); const items = queryTagsResults.items; const firstItem = items[0]; const pageSize = queryTagsResults.pageSize; const hasNext = queryTagsResults.hasNext(); const hasPrev = queryTagsResults.hasPrev(); const length = queryTagsResults.length; const query = queryTagsResults.query; return items; } catch (error) { console.error(error); } } /* Returns: * [ * { * "_createdDate": "2022-07-19T10:30:03.607Z", * "_id": "32970480-e53b-46e7-b52f-fba810a0b45d", * "_updatedDate": "2022-07-19T10:30:03.607Z", * "label": "my tag", * "language": "en", * "postCount": 1, * "publishedPostCount": 1, * "slug": "my-tag", * "translationId": "" * }, * { * "_createdDate": "2022-07-21T14:52:58.099Z", * "_id": "6a67d2ea-b758-49f1-a2bd-cce214246809", * "_updatedDate": "2022-07-21T14:52:58.099Z", * "label": "your tag", * "language": "en", * "postCount": 2, * "publishedPostCount": 2, * "slug": "your-tag", * "translationId": "" * } * { * "_createdDate": "2022-07-22T09:27:45.883Z", * "_id": "28230621-702d-4dab-af68-7a2a9b152fae", * "_updatedDate": "2022-07-22T09:27:45.883Z", * "label": "their tag", * "language": "en", * "postCount": 3, * "publishedPostCount": 3, * "slug": "their-tag", * "translationId": "" * }, * ] */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?