index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const Geo = require("./geo/index");
  4. const collection_1 = require("./collection");
  5. const command_1 = require("./command");
  6. const index_1 = require("./serverDate/index");
  7. const index_2 = require("./regexp/index");
  8. const index_3 = require("./transaction/index");
  9. const index_4 = require("./ObjectId/index");
  10. var query_1 = require("./query");
  11. exports.Query = query_1.Query;
  12. var collection_2 = require("./collection");
  13. exports.CollectionReference = collection_2.CollectionReference;
  14. var document_1 = require("./document");
  15. exports.DocumentReference = document_1.DocumentReference;
  16. class Db {
  17. constructor(config) {
  18. this.config = config;
  19. this.Geo = Geo;
  20. this.serverDate = index_1.ServerDateConstructor;
  21. this.command = command_1.Command;
  22. this.RegExp = index_2.RegExpConstructor;
  23. this.ObjectId = index_4.ObjectIdConstructor;
  24. this.startTransaction = index_3.startTransaction;
  25. this.runTransaction = index_3.runTransaction;
  26. }
  27. collection(collName) {
  28. if (!collName) {
  29. throw new Error('Collection name is required');
  30. }
  31. return new collection_1.CollectionReference(this, collName);
  32. }
  33. createCollection(collName) {
  34. let request = new Db.reqClass(this.config);
  35. const params = {
  36. collectionName: collName
  37. };
  38. return request.send('database.addCollection', params);
  39. }
  40. }
  41. exports.Db = Db;