Filtro composto
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Use um filtro composto.
Explore mais
Para ver documentação detalhada que inclui este exemplo de código, consulte o seguinte:
Exemplo de código
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],[],[[["\u003cp\u003eThe content demonstrates how to use composite filters in Datastore queries across multiple programming languages, including C#, Go, Java, Node.js, PHP, Python, and Ruby.\u003c/p\u003e\n"],["\u003cp\u003eEach code example filters entities of kind "Task" to find those where the "done" property is false and the "priority" property is 4.\u003c/p\u003e\n"],["\u003cp\u003eThe provided documentation links to instructions for installing client libraries, accessing API references, and setting up Application Default Credentials for local development environments.\u003c/p\u003e\n"],["\u003cp\u003eThe samples are utilizing the datastore.query functionality in each of the provided programming languages to build the necessary filter.\u003c/p\u003e\n"],["\u003cp\u003eThe examples showcase the syntax for creating a query with multiple filters, specifically using composite or logical "AND" filters, for each supported language.\u003c/p\u003e\n"]]],[],null,["Use a composite filter.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Datastore queries](/datastore/docs/concepts/queries)\n\nCode sample \n\nC#\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode C# API\nreference documentation](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest).\n\n\nTo authenticate to Datastore mode, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n Query query = new Query(\"Task\")\n {\n Filter = Filter.And(Filter.Equal(\"done\", false),\n Filter.Equal(\"priority\", 4)),\n };\n\nGo\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Go API\nreference documentation](https://cloud.google.com/go/docs/reference/cloud.google.com/go/datastore/latest).\n\n\nTo authenticate to Datastore mode, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n query := datastore.NewQuery(\"Task\").\n \tFilterField(\"Done\", \"=\", false).\n \tFilterField(\"Priority\", \"=\", 4)\n\nJava\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Java API\nreference documentation](https://cloud.google.com/java/docs/reference/google-cloud-datastore/latest/history).\n\n\nTo authenticate to Datastore mode, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n Query\u003cEntity\u003e query =\n Query.newEntityQueryBuilder()\n .setKind(\"Task\")\n .setFilter(\n CompositeFilter.and(\n PropertyFilter.eq(\"done\", false), PropertyFilter.eq(\"priority\", 4)))\n .build();\n\nNode.js\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Node.js API\nreference documentation](https://cloud.google.com/nodejs/docs/reference/datastore/latest).\n\n\nTo authenticate to Datastore mode, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n const query = datastore\n .createQuery('Task')\n .filter(\n and([\n new PropertyFilter('done', '=', false),\n new PropertyFilter('priority', '=', 4),\n ]),\n );\n\nPHP\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode PHP API\nreference documentation](https://googleapis.github.io/google-cloud-php/#/docs/cloud-datastore/latest).\n\n\nTo authenticate to Datastore mode, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n $query = $datastore-\u003equery()\n -\u003ekind('Task'\u003e;)\n -filter('done', &\u003e#39;=', false)\n -filter('priority', '=', 4);\n\nPython\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Python API\nreference documentation](https://cloud.google.com/python/docs/reference/datastore/latest).\n\n\nTo authenticate to Datastore mode, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from google.cloud import https://cloud.google.com/python/docs/reference/datastore/latest/\n\n # For help authenticating your client, visit\n # https://cloud.google.com/docs/authentication/getting-started\n client = https://cloud.google.com/python/docs/reference/datastore/latest/.https://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.client.Client.html()\n\n query = client.https://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.client.Client.html#google_cloud_datastore_client_Client_query(kind=\"Task&quohttps://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.query.Query.html#google_cloud_datastore_query_Query_add_filterhttps://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.query.Query.html#google_cloud_datastore_query_Query_add_filteradd_filthttps://cloud.google.com/python/docs/reference/datastore/latest/https://cloud.google.com/python/docs/reference/datastore/latest/=datasthttps://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.query.PropertyFilter.htmlhttps://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.query.PropertyFilter.htmlertyFilter(\"done\",https://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.query.Query.html#google_cloud_datastore_query_Query_add_filteruot;, Fahttps://cloud.google.com/python/docs/reference/datastore/latest/https://cloud.google.com/python/docs/reference/datastore/latest/ry.add_https://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.query.PropertyFilter.htmlhttps://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.query.PropertyFilter.htmldatastore.query.PropertyFilter(\"priority\", \"=\", 4))\n\nRuby\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Ruby API\nreference documentation](/ruby/docs/reference/google-cloud-datastore/latest).\n\n\nTo authenticate to Datastore mode, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n query = datastore.query(\"Task\")\n .where(\"done\", \"=\", false)\n .where(\"priority\", \"=\", 4)\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=datastore)."]]