Build-Dienst
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Erstellen Sie einen Dienst mit verschiedenen CRUD-Methoden.
Weitere Informationen
Eine ausführliche Dokumentation, die dieses Codebeispiel enthält, finden Sie hier:
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content focuses on building a service using Datastore mode and provides code samples in multiple languages, including C#, Go, Java, Node.js, PHP, Python, and Ruby.\u003c/p\u003e\n"],["\u003cp\u003eThe content highlights how to create an authorized Datastore service using Application Default Credentials and how to install and use the client library for Datastore mode in each language.\u003c/p\u003e\n"],["\u003cp\u003eEach section offers links to detailed API reference documentation for the respective language, providing users with in-depth resources for further learning.\u003c/p\u003e\n"],["\u003cp\u003eThe content directs users to the "Google Cloud sample browser" to find code examples for other Google Cloud products, helping them explore more services and features.\u003c/p\u003e\n"],["\u003cp\u003eThe content guides users to set up Application Default Credentials for authenticating to Datastore mode, and provides them with a link to setting this up for a local environment.\u003c/p\u003e\n"]]],[],null,["Build a service by using various CRUD methods.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Getting started with the Firestore in Datastore mode API](/datastore/docs/datastore-api-tutorial)\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 // Create an authorized Datastore service using Application Default Credentials.\n _db = DatastoreDb.Create(projectId);\n // Create a Key factory to construct keys associated with this project.\n _keyFactory = _db.CreateKeyFactory(\"Task\");\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 import (\n \t\"context\"\n \t\"log\"\n\n \t\"cloud.google.com/go/datastore\"\n )\n\n func createClient(projectID string) (*datastore.https://cloud.google.com/go/docs/reference/cloud.google.com/go/datastore/latest/index.html#cloud_google_com_go_datastore_Client, error) {\n \tctx := context.Background()\n \tclient, err := datastore.https://cloud.google.com/go/docs/reference/cloud.google.com/go/datastore/latest/index.html#cloud_google_com_go_datastore_Client_NewClient(ctx, projectID)\n \tif err != nil {\n \t\tlog.Fatalf(\"Could not create datastore client: %v\", err)\n \t}\n \t// Note: call the following from main() to ensure the client\n \t// properly frees all resources.\n \t// defer client.Close()\n \treturn client, nil\n }\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 // Create an authorized Datastore service using Application Default Credentials.\n private final Datastore datastore = DatastoreOptions.getDefaultInstance().getService();\n\n // Create a Key factory to construct keys associated with this project.\n private final KeyFactory keyFactory = datastore.newKeyFactory().setKind(\"Task\");\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 // By default, the client will authenticate using the service account file\n // specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use\n // the project specified by the GCLOUD_PROJECT environment variable. See\n // https://googlecloudplatform.github.io/google-cloud-node/#/docs/datastore/latest/guides/authentication\n const {Datastore} = require('https://cloud.google.com/nodejs/docs/reference/datastore/latest/overview.html');\n\n // Creates a client\n const datastore = new https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/datastore.html();\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 use Google\\Cloud\\Datastore\\DatastoreClient;\n\n /**\n * Create a Cloud Datastore client.\n *\n * @param string $projectId The Google Cloud project ID.\n */\n function build_service(string $projectId)\n {\n $datastore = new DatastoreClient(['projectId' =\u003e $projectId]);\n return $datastore;\n }\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 def create_client(project_id):\n return https://cloud.google.com/python/docs/reference/datastore/latest/.https://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore.client.Client.html(project_id)\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 require \"google/cloud/datastore\"\n\n datastore = Google::Cloud::https://cloud.google.com/ruby/docs/reference/google-cloud-datastore/latest/Google-Cloud-Datastore.html.https://cloud.google.com/ruby/docs/reference/google-cloud-datastore/latest/Google-Cloud-Datastore.html\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)."]]