Skip to content

feat: object params in react native sdk #1145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2025

Conversation

ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Aug 9, 2025

What does this PR do?

continuation of the other pr to implement object params in react native sdk as well

Test Plan

	/**
     * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results.
     *
     * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name
     * @param {string} search - Search term to filter your list results. Max length: 256 chars.
     * @throws {AppwriteException}
     * @returns {Promise}
     * @deprecated This API has been deprecated since 1.8.0. Please use `Grids.listDatabases` instead.
     */
    list(params: { queries?: string[], search?: string  }): Promise<Models.DatabaseList>;
    /**
     * @deprecated Parameter-based methods will be removed in the upcoming version.
     * Please use the object based method instead for better developer experience.
     *
     * @example
     * // Old (deprecated)
     * list(queries?: string[], search?: string): Promise<Models.DatabaseList>;
     *
     * // New (object based)
     * list(params: { queries?: string[], search?: string  }): Promise<Models.DatabaseList>;
     */
    list(queries?: string[], search?: string): Promise<Models.DatabaseList>;
    list(
        paramsOrFirst?: { queries?: string[], search?: string } | string[],
        ...rest: [(string)?]    
    ): Promise<Models.DatabaseList> {
        let params: { queries?: string[], search?: string };

        if (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) {
            params = paramsOrFirst as { queries?: string[], search?: string };
        } else {
            params = {
                queries: paramsOrFirst as string[],
                search: rest[0] as string            
            };
        }

        const queries = params.queries;
        const search = params.search;

        const apiPath = '/databases';
        const payload: Payload = {};

        if (typeof queries !== 'undefined') {
            payload['queries'] = queries;
        }

        if (typeof search !== 'undefined') {
            payload['search'] = search;
        }

        const uri = new URL(this.client.config.endpoint + apiPath);
        return this.client.call('get', uri, {
        }, payload);
    }

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

yes.

@abnegate abnegate merged commit 81509c3 into master Aug 11, 2025
38 checks passed
@abnegate abnegate deleted the feat-object-params-react-native branch August 11, 2025 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants