-
Notifications
You must be signed in to change notification settings - Fork 0
/
cosmos-rus.js
27 lines (21 loc) · 911 Bytes
/
cosmos-rus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { CosmosClient } = require('@azure/cosmos');
const accountEndpoint = 'https://youcount.documents.azure.com'; // :10255
const accountKey = 'XXXXXXXXXXXXX==';
const databaseId = 'mytest';
const endpoint = accountEndpoint; // Add your endpoint
const key = accountKey; // Add the masterkey of the endpoint
const client = new CosmosClient({ endpoint, key });
const databaseDefinition = { id: "mytest3" };
const collectionDefinition = { id: "fourth" };
const requestOptions = {
offerThroughput: 600
};
async function helloCosmos() {
const { database } = await client.databases.createIfNotExists(databaseDefinition);
console.log("created database");
const { container } = await database.containers.createIfNotExists(collectionDefinition, requestOptions);
console.log("created collection with RU: ", requestOptions.offerThroughput);
}
helloCosmos().catch(err => {
console.error(err);
});