All files / tcb-admin-node/lib/database db.js

90.48% Statements 19/21
25% Branches 1/4
80% Functions 4/5
90.48% Lines 19/21
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 28 29 30 31 32 33 34 35 36 37 38 39 40  8x 8x 8x 8x 8x 8x 8x 8x     3x 3x 3x 3x           3x     3x     3x 3x     3x 3x             8x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Geo = require("./geo");
const collection_1 = require("./collection");
const command_1 = require("./command");
const serverDate_1 = require("./serverDate");
const request_1 = require("./request");
const regexp_1 = require("./regexp");
const actionName = require("../constants/actionName");
class Db {
    constructor(config) {
        this.config = config;
        this.Geo = Geo;
        this.command = new command_1.Command();
        this.RegExp = regexp_1.RegExpConstructor;
    }
    serverDate({ offset = 0 } = {}) {
        return new serverDate_1.ServerDate({ offset });
    }
    collection(collName) {
        Iif (!collName) {
            throw new Error("Collection name is required");
        }
        return new collection_1.CollectionReference(this, collName);
    }
    createCollection(collName) {
        let request = new request_1.Request(this);
        const params = {
            CollectionName: collName
        };
        return request.send(actionName.CreateCollection, params).then((res) => {
            return {
                requestId: res.RequestId,
                message: res.Result
            };
        });
    }
}
exports.Db = Db;