@@ -3,9 +3,10 @@ const inquirer = require("inquirer");
3
3
const { projectsCreate } = require("./projects");
4
4
const { storageCreateBucket } = require("./storage");
5
5
const { messagingCreateTopic } = require("./messaging");
6
+ const { databasesCreateCollection } = require("./databases");
6
7
const { sdkForConsole } = require("../sdks");
7
8
const { localConfig } = require("../config");
8
- const { questionsCreateProject, questionsCreateBucket, questionsCreateMessagingTopic } = require("../questions");
9
+ const { questionsCreateProject, questionsCreateBucket, questionsCreateMessagingTopic, questionsCreateCollection } = require("../questions");
9
10
const { success, error, actionRunner, commandDescriptions } = require("../parser");
10
11
11
12
const create = new Command("create")
@@ -55,7 +56,25 @@ const createBucket = async () => {
55
56
};
56
57
57
58
const createCollection = async () => {
59
+ let response = {}
60
+ const answers = await inquirer.prompt(questionsCreateCollection)
61
+ if (!answers.database || !answers.collection || !answers.id || !answers.documentSecurity) process.exit(1)
62
+
63
+ try {
64
+ response = await databasesCreateCollection({
65
+ databaseId: answers.database,
66
+ collectionId: answers.id,
67
+ name: answers.collection,
68
+ documentSecurity: answers.documentSecurity.toLowerCase() === 'yes',
69
+ enabled: true,
70
+ parseOutput: false
71
+ })
58
72
73
+ localConfig.addCollection(response);
74
+ success();
75
+ } catch (e) {
76
+ error(e.getMessage ?? 'Unknown error occurred. Please try again');
77
+ }
59
78
};
60
79
61
80
const createTopic = async () => {
@@ -70,7 +89,7 @@ const createTopic = async () => {
70
89
parseOutput: false
71
90
})
72
91
73
- {# localConfig.addMessagingTopic(response);#}
92
+ {# localConfig.addMessagingTopic(response); #}
74
93
success();
75
94
} catch (e) {
76
95
error(e.getMessage ?? 'Unknown error occurred. Please try again');
0 commit comments