No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

firestore-indexes-list.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const command_1 = require("../command");
  5. const clc = require("colorette");
  6. const fsi = require("../firestore/indexes");
  7. const logger_1 = require("../logger");
  8. const requirePermissions_1 = require("../requirePermissions");
  9. const types_1 = require("../emulator/types");
  10. const commandUtils_1 = require("../emulator/commandUtils");
  11. exports.command = new command_1.Command("firestore:indexes")
  12. .description("List indexes in your project's Cloud Firestore database.")
  13. .option("--pretty", "Pretty print. When not specified the indexes are printed in the " +
  14. "JSON specification format.")
  15. .before(requirePermissions_1.requirePermissions, ["datastore.indexes.list"])
  16. .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
  17. .action(async (options) => {
  18. const indexApi = new fsi.FirestoreIndexes();
  19. const indexes = await indexApi.listIndexes(options.project);
  20. const fieldOverrides = await indexApi.listFieldOverrides(options.project);
  21. const indexSpec = indexApi.makeIndexSpec(indexes, fieldOverrides);
  22. if (options.pretty) {
  23. logger_1.logger.info(clc.bold(clc.white("Compound Indexes")));
  24. indexApi.prettyPrintIndexes(indexes);
  25. if (fieldOverrides) {
  26. logger_1.logger.info();
  27. logger_1.logger.info(clc.bold(clc.white("Field Overrides")));
  28. indexApi.printFieldOverrides(fieldOverrides);
  29. }
  30. }
  31. else {
  32. logger_1.logger.info(JSON.stringify(indexSpec, undefined, 2));
  33. }
  34. return indexSpec;
  35. });