models/communities/UsersQuery.js

import UserId from '../UserId';

export default class UsersQuery {
    /**
     * Creates a UsersQuery
     *
     * @constructor UsersQuery
     * @param {object} params
     * @param {string} params.searchTerm - Search term.
     * @param {UserId} params.userId - User ID.
     */
    constructor(params) {
        this.searchTerm = params.searchTerm || null;
        this.userId = params.userId || null;
    }

    /**
     * Create a query to find users, that have query string in their Display Name.
     *
     * @memberof UsersQuery
     * @param {string} searchTerm - Part of display name.
     * @return {UsersQuery} New instance.
     */
    static find(searchTerm) {
        return new UsersQuery({ searchTerm });
    }

    /**
     * Get users followed by a specific user.
     *
     * @memberof UsersQuery
     * @param {UserId} userId - ID of user.
     * @return {UsersQuery} New instance.
     */
    static followedBy(userId) {
        return new UsersQuery({ userId });
    }

    /**
     * Get suggested users.
     *
     * @memberof UsersQuery
     * @return {UsersQuery} New instance.
     */
     static suggested() {
        const query = new UsersQuery({});
        query.suggested = true;
        return query;
    }
}