models/communities/SearchQuery.js

import CommunitiesEntityType from './CommunitiesEntityType.js';

export default class SearchQuery {
    /**
     * Creates an SearchQuery
     *
     * @constructor SearchQuery
     */
    constructor(searchTerm) {
        this.searchTerm = searchTerm || null;
    }

    /**
     * Get all entities.
     *
     * @memberof SearchQuery
     * @return {SearchQuery} A new query.
     */
     static all() {
        return new SearchQuery();
    }

    /**
     * Find entities.
     *
     * @memberof SearchQuery
     * @param {string} searchTerm - String to search.
     * @return {SearchQuery} A new query.
     */
     static find(searchTerm) {
        return new SearchQuery(searchTerm);
    }

    /**
     * Get only trending entities.
     *
     * @memberof SearchQuery
     * @instance
     * @param {CommunitiesEntityType[]} entities List of entities to search.
     * @return {SearchQuery} Same query.
     */
    inEntities (entities) {
        this.entities = entities;
        return this;
    }

    /**
     * Get entities with the specified properties.
     *
     * @memberof SearchQuery
     * @instance
     * @param {Object<string, string>} properties - Properties.
     * @return {SearchQuery} same query.
     */
    withProperties(properties) {
        this.properties = properties;
        return this;
    }

    /**
     * Get entities with the specified labels.
     *
     * @memberof SearchQuery
     * @instance
     * @param {string[]} labels - Labels list.
     * @return {SearchQuery} same query.
     */
    withLabels(labels) {
        this.labels = labels;
        return this;
    }
}