使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Firebase Data Connect
plat_ios
plat_android
plat_web
plat_flutter
Firebase 首款关系型数据库解决方案,适用于希望使用 Cloud SQL for PostgreSQL 和类型安全的移动和 Web SDK 构建安全且可扩缩的应用的开发者。了解详情。
Firebase Data Connect 是一项面向移动应用和 Web 应用的关系型数据库服务,可让您使用由 Cloud SQL 提供支持的全代管式 PostgreSQL 数据库构建和扩缩应用。它使用与 Firebase Authentication 很好集成的 GraphQL 技术提供安全的架构、查询和更改管理。您可以通过 Kotlin Android、iOS、Flutter 和 Web 中的 SDK 支持,快速将此产品集成到移动应用和 Web 应用中。
借助 Data Connect,您可以声明应用的数据模型以及应用所需的确切查询。我们会根据您的数据模型自动创建适合您的数据模型的 PostgreSQL 数据库架构、与数据库通信的安全服务器端点,以及为与服务器端点通信的客户端应用创建类型安全的 SDK。它就像是为您的特定应用量身定制的“自动驾驶应用服务器”。
主要功能
由 Cloud SQL for PostgreSQL 提供支持 |
依托这项全代管式数据库服务,在 Google Cloud 上设置、维护、管理和控制 PostgreSQL 关系型数据库。 |
向量搜索 |
Data Connect 支持向量搜索,可帮助开发者构建依托 AI 技术的应用。 |
多平台 SDK |
Firebase Data Connect 提供适用于 Kotlin Android、iOS、Flutter 和 Web 的多平台 SDK。 |
基于用户的身份验证 |
Data Connect 支持最终用户身份验证,可确保只有获授权的用户才能访问数据。 |
Visual Studio Code 扩展程序 |
使用 GraphQL 直接从 Visual Studio Code 编辑器轻松开发架构,以及管理查询和更改。 |
模拟器 |
Firebase Data Connect 包含一个模拟器,可让您使用本地数据库测试应用,而无需部署到生产环境。 |
Gemini in Firebase 提供的 AI 辅助功能 | 通过 Gemini in Firebase,以便使用自然语言按需生成查询和变更,并直接在 Firebase 控制台中对其进行测试。如需了解详情,请参阅使用 AI assistance for Data Connect 进行查询和变更。 |
工作原理
Firebase Data Connect 的顶级资源是服务,表示可由开发者定义并由最终用户调用的托管式 GraphQL API。架构是服务的应用数据模型,主要表示为 GraphQL 源文件集合,以及附加数据源(例如 Cloud SQL 实例)的具体配置。每个服务只能有一个架构。最后,连接器是指已定义为针对服务的架构进行操作的查询和更改集合。每项服务可以有多个连接器(例如,如果您为共享车公司开发了“乘客”应用和“司机”应用)。
您的 Data Connect 架构会明确映射到特定的底层 PostgreSQL 数据库架构。Data Connect 包含用于根据应用架构的更改自动生成执行架构迁移所需的 SQL DDL 的工具。Data Connect 会根据您的应用架构自动生成其他 GraphQL 架构,以查询和操作数据模型。
定义应用架构后,您可以编写预定义的查询和更改,以便在应用中读取和写入数据。Data Connect 查询和更改操作不是由客户端代码提交并在服务器上执行的。相反,在部署时,这些 Data Connect 操作会存储在服务器上,就像 Cloud Functions 函数一样。这可以简化代码管理和客户端代码开发。在特权环境(例如 Firebase 控制台)中,使用 Data Connect VS Code 扩展程序,您可以使用适当的 Google IAM 凭据执行管理操作的临时操作。
对于客户端代码,每个受支持的平台都有一个核心 SDK,用于处理连接到后端、发出请求和处理响应。这些 SDK 不支持架构,必须以非结构化数据的形式提供操作名称和变量。每个受支持的平台还具有生成的 SDK。在您定义数据模型和操作时,机器上的工具会自动生成特定于应用的强类型 SDK。这些 SDK 将“封装”核心 SDK,以实现类型安全性、人体工学设计以及数据验证等其他功能。
实现流程
|
架构原型设计 |
在本地环境中使用工具,对数据库架构(包括使用矢量类型的设计)进行原型设计 |
|
设计操作原型 |
根据自动生成的查询和更改构建适用于客户端应用的预定义查询和更改操作 |
|
生成类型安全的 SDK |
根据架构和操作生成并测试类型安全的 SDK,然后实现客户端代码 |
|
部署架构和操作 |
为 Firebase Data Connect 服务部署架构和操作 |
|
部署客户端 |
部署客户端代码 |
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["Firebase Data Connect \nplat_ios plat_android plat_web plat_flutter \nFirebase's first relational database solution for\ndevelopers who want to create secure and scalable apps with Cloud SQL for\nPostgreSQL and type-safe mobile and web SDKs. [Learn more](https://firebase.google.com/products/data-connect).\n\nFirebase Data Connect is a relational database service for mobile and web\napps that lets you build and scale using a fully-managed PostgreSQL\ndatabase powered by Cloud SQL. It provides secure schema, query and\nmutation management using GraphQL technology that integrates well with\nFirebase Authentication. You can quickly integrate this product into your mobile and\nweb apps with SDK support in Kotlin Android, iOS, Flutter, and web.\n\nData Connect lets you declare your application's data model and the\nexact queries needed by your application. Using your data model we automatically\ncreate a PostgreSQL database schema to fit your data model, secure server\nendpoints that talk to the database, and type-safe SDKs for your client\napplication that talk to the server endpoints. It's like a \"self-driving app\nserver\" made-to-order for your specific application.\n\nKey capabilities\n\n|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Backed by Cloud SQL for PostgreSQL | Rely on a fully-managed database service that helps you set up, maintain, manage, and administer your PostgreSQL relational databases on Google Cloud. |\n| Vector search | Data Connect supports vector search for developers to build AI-powered applications. |\n| Multiple platform SDKs | Firebase Data Connect offers multi-platform SDKs, for Kotlin Android, iOS, Flutter, and web. |\n| User-based authentication | Data Connect supports end-user authentication, ensuring that only authorized users can access the data. |\n| Visual Studio Code extension | Offers easy schema development, and query and mutation management, directly from your Visual Studio Code editor using GraphQL. |\n| Emulator | Firebase Data Connect includes an emulator that lets you test your app with a local database without having to deploy to production. |\n| AI assistance from Gemini in Firebase | Use Gemini in Firebase to generate queries and mutations on-demand using natural language and test them directly in the Firebase console. Learn more at [Use AI assistance for Data Connect for queries and mutations](/docs/data-connect/ai-assistance). |\n\nHow does it work?\n\nThe top-level resource for Firebase Data Connect is a *service* , which\nrepresents a managed GraphQL API that can be defined by developers and called by\nend users. Your *schema* is the app data model for a service, represented\nprimarily as a collection of GraphQL source files, as well as specific\nconfiguration for attached datasources (such as Cloud SQL instances). There can\nbe only one schema per service. Finally, your *connectors* are collections of\nqueries and mutations that have been defined to operate against a service's\nschema. There can be many connectors per service (for instance if you have a\n\"rider\" app and a \"driver\" app for your rideshare company).\n\nYour Data Connect schema maps explicitly to a specific underlying\nPostgreSQL database schema. Data Connect includes tooling to\nautomatically generate the SQL DDL needed to perform schema migrations based on\nchanges to the app schema. Based on your app schema, Data Connect\nautomatically generates additional GraphQL schema to query and manipulate the\ndata model.\n\nOnce your app schema is defined, you can write predefined queries and mutations\nthat are executed to read and write data in the application.\nData Connect queries and mutations are not submitted by client code\nand executed on the server. Instead, when deployed, these Data Connect\noperations are stored on the server, like Cloud Functions. This simplifies code\nmanagement, and development of your client code. In privileged environments,\nlike the Firebase console and using our Data Connect VS Code extension,\nyou can execute ad hoc operations with appropriate Google IAM credentials for\nadministrative operations.\n\nFor client code, each supported platform has a *core SDK* that handles\nconnecting to the backend, issuing requests, and processing responses. These\nSDKs are not schema-aware and must be supplied with operation names and\nvariables as unstructured data. Each supported platform also has a\n*generated SDK*. As you define your data model and operations, tooling on your\nmachine will automatically generate strongly-typed SDKs specific to the\napplication. These SDKs will \"wrap\" the core SDKs for type safety, ergonomics,\nand other features such as data validation and more down the road.\n\nImplementation path\n\n|---|------------------------------|-----------------------------------------------------------------------------------------------------------------------|\n| | Prototype your schema | Prototype your database schema, including designs using vector types, starting in a local environment with tooling |\n| | Prototype your operations | Build predefined query and mutation operations for client apps based on automatically-generated queries and mutations |\n| | Generate type-safe SDKs | Generate and test type-safe SDKs from your schema and operations, then implement client-side code |\n| | Deploy schema and operations | Deploy the schema and operations for your Firebase Data Connect service |\n| | Deploy clients | Deploy your client code |\n\nNext steps\n\n- Try out Data Connect right now: explore a quickstart app repository and build a fully-featured Data Connect app by following our [codelab for web](/codelabs/firebase-dataconnect-web), [codelab for iOS](/codelabs/firebase-dataconnect-ios), or [codelab for Android](/codelabs/firebase-dataconnect-android).\n- If you'd like to see the Firebase Data Connect development flow in action, read through the [Get started guide](/docs/data-connect/quickstart).\n- Learn about Data Connect [pricing and billing](/docs/data-connect/pricing)."]]