تتيح لك واجهة سطر الأوامر Firebase إدارة مشاريعك على Firebase في دليل مشروع محلي، يمكن التحكّم في إصداراته. ويشمل ذلك SQL Connect الخدمات في مشاريعك، والموصِّلات لهذه الخدمات، والموارد مثل مخططات البيانات وطلبات البحث ومصادر التعديل لكل موصِّل. تتيح لك واجهة سطر الأوامر (CLI) أيضًا تثبيت محاكي Firebase SQL Connectوتشغيله. تُعدّ واجهة سطر الأوامر (CLI) بديلاً فعالاً للعمل في "وحدة تحكّم Firebase".Firebase
للحصول على تعليمات بشأن تثبيت تجربة واجهة سطر الأوامر (CLI) في Firebase لبرنامج "المعاينة الخاصة"، وأوامر واجهة سطر الأوامر (CLI) ذات الصلة بـ SQL Connect، يُرجى الاطّلاع على مرجع واجهة سطر الأوامر (CLI) في Firebase.
يوثّق هذا الدليل المرجعي ما يلي:
- الإدخالات الخاصة بـ SQL Connect في ملف إعدادات مشروعك
firebase.json - إعدادات SQL Connect في
dataconnect.yamlوconnector.yaml
ملفات إعدادات مشروع Firebase
مرجع إعدادات firebase.json
استخدِم مفاتيح dataconnect لإعداد خدمة واحدة أو أكثر من خدمات SQL Connect
في مشروعك.
dataconnect: {
source: string // Path to the directory containing the dataconnect.yaml service file.
}
مرجع إعدادات dataconnect.yaml
يخزِّن ملف dataconnect.yaml معلومات الإعدادات حول مواقع مصادر مخططات التطبيقات ومصادر الموصِّلات ومعلومات الاتصال بمصدر البيانات. يعمل الملف أيضًا كمحدِّد لدليل المشروع في
Firebase واجهة سطر الأوامر (CLI).
يتحكّم المفتاح schemaValidation في مستوى التحقّق من صحة المخطط الذي يتم إجراؤه عند نقل المخططات أثناء عملية النشر. في حال عدم ضبط أي قيمة، يكون سلوك الأمر dataconect:sql:migrate هو تطبيق التغييرات المتوافقة ومطالبتك قبل تنفيذ أي تغييرات صارمة. عند ضبط هذا المفتاح، يكون السلوك على النحو التالي:
- وضع
STRICT: يجب أن يتطابق مخطط قاعدة البيانات تمامًا مع مخطط التطبيق قبل أن يصبح بالإمكان نشر مخطط التطبيق. سيتم حذف أي جداول أو أعمدة غير مستخدَمة في مخطط SQL Connect من قاعدة البيانات. - وضع
COMPATIBLE: يجب أن يكون مخطط قاعدة البيانات متوافقًا مع مخطط التطبيق قبل أن يصبح بالإمكان نشر مخطط التطبيق، وتُعدّ أي تغييرات إضافية اختيارية. يعني ذلك أنّ عمليات نقل المخططات تستند إلى مخطط التطبيق الذي تكتبه. تظل العناصر في قاعدة البيانات غير المعدَّلة إذا لم يستخدمها مخطط التطبيق. لذلك، بعد عملية النشر، قد تحتوي الخلفية على مخططات وجداول وأعمدة غير مستخدَمة.
تم توضيح قيم المفاتيح الأخرى في هذا الملف في التعليقات أدناه.
# The top-level Firebase SQL Connect YAML file.
# The Firebase SQL Connect API version to target.
# Optional. Defaults to the latest version.
specVersion: string
# The ID of the Firebase SQL Connect service resource.
# Required.
serviceId: string
# The location of the Firebase SQL Connect service.
# Required.
location: string
# Required.
schema:
# Relative path to directory for schema definitions.
# Recursively loads all .gql files in this directory.
# Optional. If not present, defaults to ./schema.
source: string
# Datasource connection information.
# Required.
datasource:
# Required.
postgresql:
# The name of the PostgreSQL database.
# Required.
database: string
cloudSql:
# The ID of the Cloud SQL instance resource.
# Required.
instanceId: string
# Schema validation mode for schema migrations.
# Defaults to unspecified/commented out, meaning you are prompted to
# review all changes during migration.
# If desired, uncomment and indicate one of "STRICT" or "COMPATIBLE".
schemaValidation: string
# Required.
# Relative paths to directories for connector definitions.
# Recursively loads all .gql files in the listed directories.
# All directories specified MUST contain a connector.yaml file.
connectorDirs: [string]
يفترض ملف YAML بنية دليل تلقائية (قابلة للإعداد) على النحو التالي:
./(project root)
/dataconnect
dataconnect.yaml
/schema
*.gql
/example
connector.yaml
*.gql
مرجع إعدادات connector.yaml
استخدِم connector.yaml لإعداد وضع المصادقة التلقائي وخيارات إنشاء حزمة تطوير البرامج (SDK).
# The connector-level YAML file.
# Required. The connector name of the Firebase SQL Connect connector resource.
connectorId: string
# Optional. If not specified, no generated libraries (i.e. type-safe SDKs) will
# be generated.
generate:
# Optional.
javascriptSdk:
# Path to the directory that will be updated with the latest generated
# web TypeScript SDK.
# Required.
outputDir: string
# Name of the Javascript package to be created.
# Required. Example: @dataconnect/generated
package: string
# Path to your package.json directory. If specified, the new generated
# SDK will be installed in this path.
# Optional. If not provided, the package will not be auto-installed for
# you.
packageJsonDir: string
# Enable React framework bindings.
# Optional. Default to false.
react: Boolean
# Enable Angular framework bindings.
# Optional. Default to false.
angular: Boolean
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to executeQuery() and as the
# initial result returned from subscribe().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures how results are to be cached.
# Optional. Only "memory" is allowed for JavaScript SDKs.
storage: string
# Optional.
dartSdk:
# Path to the directory that will be updated with the latest generated
# Flutter Dart SDK.
# Required.
outputDir: string
# Name of the Dart package to be created.
# Required. Example: "dataconnect_generated"
package: string
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute() and as the
# initial result returned from subscribe().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional.
# Default: "persistent" for Android and iOS targets, "memory" for web.
storage: string
# Optional.
kotlinSdk:
# Path to the directory that will be updated with the latest generated
# Android SDK.
# Required.
outputDir: string
# Name of the package to be created.
# Required. Example: com.google.firebase.dataconnect.generated
package: string
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional. Default: persistent
storage: string
# Optional.
adminNodeSdk:
# Path to the directory that will be updated with the latest generated
# Node Admin SDK.
# Required.
outputDir: string
# Path to your package.json directory. If specified, the new generated
# SDK will be installed in this path.
# Optional. If not provided, the package will not be auto-installed for
# you.
packageJsonDir: string
# Name of the package to be created (for example: @dataconnect/admin-generated).
# Required.
package: string
# Optional.
swiftSdk:
# Path to the directory that will be updated with the latest generated
# iOS Swift SDK.
# Required.
outputDir: string
# Name of the Swift package to be created.
# Required. Example: "FirebaseDataConnectGenerated"
package: string
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional. Default: persistent
storage: string