@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
116 lines (115 loc) • 4.67 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var DatabaseAccount_exports = {};
__export(DatabaseAccount_exports, {
DatabaseAccount: () => DatabaseAccount
});
module.exports = __toCommonJS(DatabaseAccount_exports);
var import_common = require("../common/index.js");
var import_ConsistencyLevel = require("./ConsistencyLevel.js");
class DatabaseAccount {
/** The list of writable locations for a geo-replicated database account. */
writableLocations = [];
/** The list of readable locations for a geo-replicated database account. */
readableLocations = [];
/**
* The self-link for Databases in the databaseAccount.
* @deprecated Use `databasesLink`
*/
get DatabasesLink() {
return this.databasesLink;
}
/** The self-link for Databases in the databaseAccount. */
databasesLink;
/**
* The self-link for Media in the databaseAccount.
* @deprecated Use `mediaLink`
*/
get MediaLink() {
return this.mediaLink;
}
/** The self-link for Media in the databaseAccount. */
mediaLink;
/**
* Attachment content (media) storage quota in MBs ( Retrieved from gateway ).
* @deprecated use `maxMediaStorageUsageInMB`
*/
get MaxMediaStorageUsageInMB() {
return this.maxMediaStorageUsageInMB;
}
/** Attachment content (media) storage quota in MBs ( Retrieved from gateway ). */
maxMediaStorageUsageInMB;
/**
* Current attachment content (media) usage in MBs (Retrieved from gateway )
*
* Value is returned from cached information updated periodically and is not guaranteed
* to be real time.
*
* @deprecated use `currentMediaStorageUsageInMB`
*/
get CurrentMediaStorageUsageInMB() {
return this.currentMediaStorageUsageInMB;
}
/**
* Current attachment content (media) usage in MBs (Retrieved from gateway )
*
* Value is returned from cached information updated periodically and is not guaranteed
* to be real time.
*/
currentMediaStorageUsageInMB;
/**
* Gets the UserConsistencyPolicy settings.
* @deprecated use `consistencyPolicy`
*/
get ConsistencyPolicy() {
return this.consistencyPolicy;
}
/** Gets the UserConsistencyPolicy settings. */
consistencyPolicy;
enableMultipleWritableLocations;
/**
* Indicates whether per-partition failover behavior is enabled for the database account.
*/
enablePerPartitionFailover = false;
// TODO: body - any
constructor(body, headers) {
this.databasesLink = "/dbs/";
this.mediaLink = "/media/";
this.maxMediaStorageUsageInMB = headers[import_common.Constants.HttpHeaders.MaxMediaStorageUsageInMB];
this.currentMediaStorageUsageInMB = headers[import_common.Constants.HttpHeaders.CurrentMediaStorageUsageInMB];
this.consistencyPolicy = body.userConsistencyPolicy ? body.userConsistencyPolicy.defaultConsistencyLevel : import_ConsistencyLevel.ConsistencyLevel.Session;
if (body[import_common.Constants.WritableLocations] && body.id !== "localhost") {
this.writableLocations = body[import_common.Constants.WritableLocations];
}
if (body[import_common.Constants.ReadableLocations] && body.id !== "localhost") {
this.readableLocations = body[import_common.Constants.ReadableLocations];
}
if (body[import_common.Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS]) {
this.enableMultipleWritableLocations = body[import_common.Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === true || body[import_common.Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === "true";
} else {
this.enableMultipleWritableLocations = false;
}
if (body[import_common.Constants.EnablePerPartitionFailover]) {
this.enablePerPartitionFailover = body[import_common.Constants.EnablePerPartitionFailover] === true || body[import_common.Constants.EnablePerPartitionFailover] === "true";
}
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DatabaseAccount
});