@cocreate/crud-server 1.16.1 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/backup.js +10 -10
- package/src/index.js +20 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.17.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.16.1...v1.17.0) (2022-12-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* database crud functions ([60ff480](https://github.com/CoCreate-app/CoCreate-crud-server/commit/60ff4809ed232a8a9b4b5ae95f2e0649773dec00))
|
|
7
|
+
|
|
1
8
|
## [1.16.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.16.0...v1.16.1) (2022-12-04)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/backup.js
CHANGED
|
@@ -34,7 +34,7 @@ class CoCreateBackup {
|
|
|
34
34
|
// try {
|
|
35
35
|
// let binaryData = null;
|
|
36
36
|
// const result = data.data;
|
|
37
|
-
// const
|
|
37
|
+
// const organization_id = socket.config.organization_id ;
|
|
38
38
|
// if (export_type === 'csv') {
|
|
39
39
|
// binaryData = await json2csv.json2csvAsync(JSON.parse(JSON.stringify(result)), {
|
|
40
40
|
// emptyFieldValue: ''
|
|
@@ -43,9 +43,9 @@ class CoCreateBackup {
|
|
|
43
43
|
// binaryData = Buffer.from(JSON.stringify(result));
|
|
44
44
|
// }
|
|
45
45
|
|
|
46
|
-
// this.wsManager.send(socket, 'downloadFileInfo', {file_name: `backup_${data['collection']}.${export_type}`, binaryData, export_type},
|
|
46
|
+
// this.wsManager.send(socket, 'downloadFileInfo', {file_name: `backup_${data['collection']}.${export_type}`, binaryData, export_type}, organization_id);
|
|
47
47
|
|
|
48
|
-
// this.wsManager.sendBinary(socket, binaryData,
|
|
48
|
+
// this.wsManager.sendBinary(socket, binaryData, organization_id);
|
|
49
49
|
|
|
50
50
|
// } catch (error) {
|
|
51
51
|
// console.log('export error', error);
|
|
@@ -68,14 +68,14 @@ class CoCreateBackup {
|
|
|
68
68
|
// try {
|
|
69
69
|
|
|
70
70
|
// var collection = this.dbClient.db(data['namespace']).collection(data["collection"]);
|
|
71
|
-
// const
|
|
71
|
+
// const organization_id = socket.config.organization_id
|
|
72
72
|
|
|
73
73
|
// var query = {};
|
|
74
74
|
|
|
75
75
|
// collection.find(query).toArray(async function(error, result) {
|
|
76
76
|
// if (!error) {
|
|
77
77
|
// let binaryData = null;
|
|
78
|
-
// self.wsManager.send(socket, 'downloadFileInfo', {file_name: `backup_${data['collection']}.${export_type}`},
|
|
78
|
+
// self.wsManager.send(socket, 'downloadFileInfo', {file_name: `backup_${data['collection']}.${export_type}`}, organization_id);
|
|
79
79
|
// if (export_type === 'csv') {
|
|
80
80
|
// binaryData = await json2csv.json2csvAsync(JSON.parse(JSON.stringify(result)), {
|
|
81
81
|
// emptyFieldValue: ''
|
|
@@ -84,7 +84,7 @@ class CoCreateBackup {
|
|
|
84
84
|
// binaryData = Buffer.from(JSON.stringify(result));
|
|
85
85
|
// }
|
|
86
86
|
|
|
87
|
-
// self.wsManager.sendBinary(socket, binaryData,
|
|
87
|
+
// self.wsManager.sendBinary(socket, binaryData, organization_id);
|
|
88
88
|
// }
|
|
89
89
|
// });
|
|
90
90
|
// } catch (error) {
|
|
@@ -106,7 +106,7 @@ class CoCreateBackup {
|
|
|
106
106
|
|
|
107
107
|
// console.log('import:', importCollection, importType, importFile)
|
|
108
108
|
// const self = this;
|
|
109
|
-
// // const
|
|
109
|
+
// // const organization_id = socket.config.organization_id
|
|
110
110
|
// if (!importCollection || !importType) {
|
|
111
111
|
// return;
|
|
112
112
|
// }
|
|
@@ -123,16 +123,16 @@ class CoCreateBackup {
|
|
|
123
123
|
// // todo: validate json / if json is object error happens
|
|
124
124
|
// jsonData.map((item) => delete item._id);
|
|
125
125
|
// console.log('json: ', jsonData)
|
|
126
|
-
// var collection = this.dbClient.db(
|
|
126
|
+
// var collection = this.dbClient.db(organization_id).collection(importCollection);
|
|
127
127
|
// // console.log(this.importCollection)
|
|
128
128
|
// collection.insertMany(jsonData, function(err, result) {
|
|
129
129
|
// if (!err) {
|
|
130
130
|
// self.wsManager.send(socket, 'importedFile2DB', {
|
|
131
|
-
// 'database':
|
|
131
|
+
// 'database': organization_id,
|
|
132
132
|
// 'collection': importCollection,
|
|
133
133
|
// 'import_type': importType,
|
|
134
134
|
// 'data': result
|
|
135
|
-
// },
|
|
135
|
+
// }, organization_id)
|
|
136
136
|
// }
|
|
137
137
|
// })
|
|
138
138
|
|
package/src/index.js
CHANGED
|
@@ -32,6 +32,26 @@ class CoCreateCrudServer {
|
|
|
32
32
|
return data
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
async createDatabase(data) {
|
|
36
|
+
data = await this.db('', 'createDatabase', data)
|
|
37
|
+
return data
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async readDatabase(data) {
|
|
41
|
+
data = await this.db('', 'readDatabase', data)
|
|
42
|
+
return data
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async updateDatabase(data) {
|
|
46
|
+
data = await this.db('', 'updateDatabase', data)
|
|
47
|
+
return data
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async deleteDatabase(data) {
|
|
51
|
+
data = await this.db('', 'deleteDatabase', data)
|
|
52
|
+
return data
|
|
53
|
+
}
|
|
54
|
+
|
|
35
55
|
async createCollection(data) {
|
|
36
56
|
data = await this.db('', 'createCollection', data)
|
|
37
57
|
return data
|
|
@@ -42,11 +62,6 @@ class CoCreateCrudServer {
|
|
|
42
62
|
return data
|
|
43
63
|
}
|
|
44
64
|
|
|
45
|
-
async readCollections(data) {
|
|
46
|
-
data = await this.db('', 'readCollections', data)
|
|
47
|
-
return data
|
|
48
|
-
}
|
|
49
|
-
|
|
50
65
|
async updateCollection(data) {
|
|
51
66
|
data = await this.db('', 'updateCollection', data)
|
|
52
67
|
return data
|