適用於 Node.js 的 Azure Cosmos DB 模組Azure Cosmos DB Modules for Node.js

Azure Cosmos DB 是 Microsoft 的全球散發多模型資料庫。Azure Cosmos DB is Microsoft's globally distributed, multi-model database. Azure Cosmos DB 可讓您有彈性且獨立地跨任意數目的 Azure 地理區域調整輸送量和儲存體。Azure Cosmos DB enables you to elastically and independently scale throughput and storage across any number of Azure's geographic regions. 它利用完整的服務等級協定 (SLA) 提供了輸送量、延遲、可用性和一致性的保證,這是其他資料庫服務無法提供的。It offers throughput, latency, availability, and consistency guarantees with comprehensive service level agreements (SLAs), something no other database service can offer.

Azure Cosmos DB 包含已最佳化寫入、已管理資源、無結構描述的資料庫引擎,它原生支援多重資料模型:機碼值、文件、圖形和單欄式。Azure Cosmos DB contains a write optimized, resource governed, schema-agnostic database engine that natively supports multiple data models: key-value, documents, graphs, and columnar. 它也支援許多以可延伸的方式用來存取資料的 API,包括 MongoDB、SQL、Gremlin/Graph、Azure 資料表以及 Cassandra (預覽版)。It also supports many APIs for accessing data including MongoDB, SQL, Gremlin/Graph, Azure Tables, and Cassandra (preview) in an extensible manner.

管理套件Management Package

安裝 npm 模組Install the npm module

安裝 Azure Cosmos DB npm 模組。Install the Azure Cosmos DB npm module.

npm install azure-arm-documentdb

範例Example

此範例會列出所有的 Azure Cosmos DB 帳戶。This example lists all Azure Cosmos DB accounts.

const msRestAzure = require('ms-rest-azure');
const documentDBManagementClient = require('azure-arm-documentdb');

const subscriptionId = 'your-subscription-id';

msRestAzure.interactiveLogin().then(credentials => {
  const documentDbClient = new documentDBManagementClient(credentials, subscriptionId);
  documentDbClient.databaseAccounts
    .list()
    .then(databaseAccounts => console.log('Retrieved database accounts: ', databaseAccounts));
});

範例Samples

深入探索可在應用程式中使用的 Node.js 程式碼範例Explore more sample Node.js code you can use in your apps.