Google CloudGoogle Cloud
  • Why Google
    • Groundbreaking solutions. Transformative know-how.
    • Learn more
    • Why Google Cloud
    • Choosing Google Cloud
      Reasons why people choose us
    • Trust and security
      Keep your data secure and compliant
    • Open cloud
      Scale with open, flexible technology
    • Customers and case studies
      Learn how businesses use Google Cloud
    • Analyst reports
      See how Google Cloud ranks
    • Data centers and network
      Build on the same infrastructure Google uses
    • Partners
      Tap into our global ecosystem of cloud experts
    • Google Cloud Blog
      Read the latest stories and product updates
    • Events
      Join events and learn more about Google Cloud
  • Solutions
    • By business need
    • Infrastructure modernization
      Modernize enterprise workloads
    • Data management
      Manage data securely, reliably and at scale
    • Application development
      Build and run apps on an open, secure cloud
    • Smart business analytics and AI
      Generate insights with analytics, ML, and AI
    • Productivity and work transformation
      Transform how people work together
    • Device management
    • By industry
    • Education
    • Energy
    • Financial services
    • Gaming
    • Government
    • Healthcare
    • Life sciences
    • Manufacturing
    • Telecommunications, Media & Entertainment
    • Retail
    • By role
    • DevOps
    • Marketing
    • Small business owners
    • See all solutions
  • Products
    • Google Cloud Platform
    • AI and Machine Learning
    • Speech-to-Text
    • Vision
    • Translation
    • More
    • API Management
    • Apigee API Platform
    • Cloud Endpoints
    • More
    • Compute
    • Compute Engine
    • Cloud GPUs
    • More
    • Hybrid and Multi-cloud
    • Anthos
    • Migrate for Anthos
    • GKE
    • More
    • Data Analytics
    • BigQuery
    • Cloud Datalab
    • More
    • Databases
    • Cloud SQL
    • Cloud Firestore
    • More
    • Developer Tools
    • Cloud Build
    • Cloud Code
    • Cloud SDK
    • More
    • Migration
    • Data Transfer
    • VM Migration
    • More
    • Networking
    • DNS
    • CDN
    • Virtual Private Cloud
    • More
    • Security and Identity
    • Shielded VMs
    • Cloud IAM
    • More
    • Serverless Computing
    • Cloud Run
    • App Engine
    • Cloud Functions
    • More
    • Storage
    • Cloud Storage
    • Persistent Disk
    • More
    • More Cloud Products
    • G Suite
      Gmail, Docs, Drive, Hangouts, and more
    • Google Maps Platform
      Build with real-time, comprehensive data
    • Cloud Identity
      Easily manage user identities
    • Chrome Enterprise
      Get Chrome OS devices and browser
    • Android Enterprise
      Intelligent devices, OS, and business apps
    • See all products (100+)
  • Pricing
    • Do more for less with Google Cloud
    • Contact sales
    • Google Cloud Platform
    • Overview
      Pay only for what you use with no lock-in
    • Price list
      Pricing details on each GCP product
    • Calculators
      Calculate your cloud savings
    • Free on GCP
      Learn and build on GCP for free
    • More Cloud Products
    • G Suite
    • Google Maps Platform
    • Cloud Identity
    • Hire by Google
    • Apigee
    • Firebase
    • Zync Render
  • Getting started
    • Get started with Google Cloud
    • Try GCP Free
    • Go to console
    • Resources to Start on Your Own
    • Quickstarts
      View short tutorials to help you get started
    • GCP Marketplace
      Deploy ready-to-go solutions in a few clicks
    • Training
      Enroll in on-demand or classroom training
    • Certification
      Become Google Cloud Certified
    • Get Help from an Expert
    • Consulting
      Jump-start your project with help from Google
    • Technical Account Management
      Get long-term guidance from Google
    • Find a Partner
      Work with a Partner in our global network
    • Become a Partner
      Join Google Cloud's Partner program
    • More ways to get started
  • Docs
  • Support
控制台
登入
  • Documentation
  • Node.js
More
Contact sales Get started for free
Google Cloud Google Cloud
  • Why Google
  • Solutions
  • Products
  • Pricing
  • Getting started
  • Docs More
  • Support
  • 控制台
Google Cloud Google Cloud
  • Groundbreaking solutions. Transformative know-how.
  • Learn more
  • Why Google Cloud
  • Choosing Google Cloud
  • Trust and security
  • Open cloud
  • Customers and case studies
  • Analyst reports
  • Data centers and network
  • Partners
  • Google Cloud Blog
  • Events
  • By business need
  • Infrastructure modernization
  • Data management
  • Application development
  • Smart business analytics and AI
  • Productivity and work transformation
  • Device management
  • By industry
  • Education
  • Energy
  • Financial services
  • Gaming
  • Government
  • Healthcare
  • Life sciences
  • Manufacturing
  • Telecommunications, Media & Entertainment
  • Retail
  • By role
  • DevOps
  • Marketing
  • Small business owners
  • See all solutions
  • Google Cloud Platform
  • AI and Machine Learning
  • Speech-to-Text
  • Vision
  • Translation
  • More
  • API Management
  • Apigee API Platform
  • Cloud Endpoints
  • More
  • Compute
  • Compute Engine
  • Cloud GPUs
  • More
  • Hybrid and Multi-cloud
  • Anthos
  • Migrate for Anthos
  • GKE
  • More
  • Data Analytics
  • BigQuery
  • Cloud Datalab
  • More
  • Databases
  • Cloud SQL
  • Cloud Firestore
  • More
  • Developer Tools
  • Cloud Build
  • Cloud Code
  • Cloud SDK
  • More
  • Migration
  • Data Transfer
  • VM Migration
  • More
  • Networking
  • DNS
  • CDN
  • Virtual Private Cloud
  • More
  • Security and Identity
  • Shielded VMs
  • Cloud IAM
  • More
  • Serverless Computing
  • Cloud Run
  • App Engine
  • Cloud Functions
  • More
  • Storage
  • Cloud Storage
  • Persistent Disk
  • More
  • More Cloud Products
  • G Suite
  • Google Maps Platform
  • Cloud Identity
  • Chrome Enterprise
  • Android Enterprise
  • See all products (100+)
  • Do more for less with Google Cloud
  • Contact sales
  • Google Cloud Platform
  • Overview
  • Price list
  • Calculators
  • Free on GCP
  • More Cloud Products
  • G Suite
  • Google Maps Platform
  • Cloud Identity
  • Hire by Google
  • Apigee
  • Firebase
  • Zync Render
  • Get started with Google Cloud
  • Try GCP Free
  • Go to console
  • Resources to Start on Your Own
  • Quickstarts
  • GCP Marketplace
  • Training
  • Certification
  • Get Help from an Expert
  • Consulting
  • Technical Account Management
  • Find a Partner
  • Become a Partner
  • More ways to get started
  • APIs and libraries
  • Latest Reference Docs
  • @google-cloud/firestore (legacy)
    • 1.3.x (latest)
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1.FirestoreAdminClient
        • v1beta1.FirestoreClient
        • v1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.admin.v1
        • google.firestore.v1
        • google.firestore.v1beta1
        • google.longrunning
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 1.2.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1.FirestoreAdminClient
        • v1beta1.FirestoreClient
        • v1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.admin.v1
        • google.firestore.v1
        • google.firestore.v1beta1
        • google.longrunning
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 1.1.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • v1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 1.0.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • v1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.21.x (latest)
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • v1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.20.x (latest)
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • v1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.19.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.18.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.17.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.16.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.15.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldValue
        • Firestore
        • v1beta1.FirestoreClient
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Timestamp
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.14.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • FirestoreClient
        • FirestoreClientBuilder
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.13.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • FirestoreClient
        • FirestoreClientBuilder
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.12.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • FirestoreClient
        • FirestoreClientBuilder
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.11.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • FirestoreClient
        • FirestoreClientBuilder
        • GeoPoint
        • Query
        • QueryDocumentSnapshot
        • QuerySnapshot
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.10.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • FirestoreClient
        • FirestoreClientBuilder
        • GeoPoint
        • Query
        • QuerySnapshot
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.9.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • FirestoreClient
        • FirestoreClientBuilder
        • GeoPoint
        • Query
        • QuerySnapshot
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
    • 0.8.x
      • Overview
      • About the NPM package
      • Classes
        • CollectionReference
        • DocumentChange
        • DocumentReference
        • DocumentSnapshot
        • FieldPath
        • FieldValue
        • Firestore
        • FirestoreClient
        • FirestoreClientBuilder
        • GeoPoint
        • Query
        • QuerySnapshot
        • Transaction
        • WriteBatch
        • WriteResult
      • RPC Message Types
        • google.firestore.v1beta1
        • google.protobuf
        • google.rpc
      • Other Abstract Types
      • Index of all
  • Home
  • Docs
  • Documentation
  • Node.js

@google-cloud/firestore 0.15.4 » Module: @google-cloud/firestore

@google-cloud/firestore

module

The default export of the @google-cloud/firestore package is the Firestore class.

See Firestore and ClientConfig for client methods and configuration options.

Examples

<caption>Install the client library with <a
href="https://www.npmjs.com/">npm</a>:</caption> npm install --save

Import the client library

var Firestore = require('@google-cloud/firestore');
<caption>Create a client that uses <a
href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Application
Default Credentials (ADC)</a>:</caption> var firestore = new Firestore();
<caption>Create a client with <a
href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually">explicit
credentials</a>:</caption> var firestore = new Firestore({ projectId:
'your-project-id', keyFilename: '/path/to/keyfile.json'
});

Full quickstart example:

View on GitHub
const Firestore = require('@google-cloud/firestore');

const firestore = new Firestore({
  projectId: 'YOUR_PROJECT_ID',
  keyFilename: '/path/to/keyfile.json',
});

const document = firestore.doc('posts/intro-to-firestore');

// Enter new data into the document.
document.set({
  title: 'Welcome to Firestore',
  body: 'Hello World',
}).then(() => {
  // Document created successfully.
});

// Update an existing document.
document.update({
  body: 'My first Firestore app',
}).then(() => {
  // Document updated successfully.
});

// Read the document.
document.get().then(doc => {
  // Document read successfully.
});

// Delete the document.
document.delete().then(() => {
  // Document deleted successfully.
});
本頁內容對您是否有任何幫助?請提供意見:

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

上次更新:十二月 4, 2019。

  • Google 的特色及優點

    • 選擇 Google Cloud
    • 信任與安全性
    • 開放式雲端
    • 資料中心位置
    • 客戶與個案研究
    • 分析師報告
    • 白皮書
    • 產品與定價
    • GCP 定價
    • G Suite 定價
    • Maps Platform 定價
    • 查看所有產品/服務
  • 解決方案

    • 基礎架構現代化
    • 資料管理
    • 應用程式開發
    • 智慧型商業分析與 AI
    • 生產力與工作轉型
    • 產業解決方案
    • 開發運作解決方案
    • 人力資源與招募解決方案
    • 行銷解決方案
    • 小型企業解決方案
    • 查看所有解決方案
  • 資源

    • GCP 說明文件
    • GCP 快速入門導覽課程
    • GCP Marketplace
    • G Suite Marketplace
    • 完備支援
    • 教學課程
    • 訓練
    • 認證
    • Google Developers
    • Google Cloud for Startups
    • 系統狀態
  • 互動

    • 聯絡銷售人員
    • 尋找合作夥伴
    • 成為合作夥伴
    • 網誌
    • 活動
    • Podcast
    • 社群
    • 新聞中心
    • Google Cloud 的 YouTube 頻道
    • GCP 的 YouTube 頻道
    • G Suite 的 YouTube 頻道
    • 在 Twitter 上追蹤
    • 我們正在招募人才,歡迎加入 Google Cloud!
Google 完全手冊 隱私權 網站條款 Google Cloud 服務條款
訂閱 Google Cloud 電子報
訂閱

傳送您對下列選項的寶貴意見...

這個網頁
文件意見
Node.js
產品意見