@cocreate/crud-server 1.3.4 → 1.4.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/list.js +11 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.4.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.3.4...v1.4.0) (2022-04-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* readCollections to return a list of collections ([2ad15d4](https://github.com/CoCreate-app/CoCreate-crud-server/commit/2ad15d43baf22c6dabbf56582cac182dec8876ad))
|
|
7
|
+
|
|
1
8
|
## [1.3.4](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.3.3...v1.3.4) (2022-03-06)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/list.js
CHANGED
|
@@ -9,7 +9,7 @@ class CoCreateList {
|
|
|
9
9
|
|
|
10
10
|
init() {
|
|
11
11
|
this.wsManager.on('readDocumentList', (socket, data, socketInfo) => this.readDocumentList(socket, data, socketInfo));
|
|
12
|
-
this.wsManager.on('
|
|
12
|
+
this.wsManager.on('readCollections', (socket, data, socketInfo) => this.readCollections(socket, data, socketInfo));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -40,7 +40,6 @@ class CoCreateList {
|
|
|
40
40
|
count: 0 (integer)
|
|
41
41
|
},
|
|
42
42
|
|
|
43
|
-
is_collection: true | false,
|
|
44
43
|
//. case fetch document case
|
|
45
44
|
export: true | false
|
|
46
45
|
-------- additional response data -----------
|
|
@@ -53,13 +52,11 @@ class CoCreateList {
|
|
|
53
52
|
setTimeout(resolve, ms);
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
// await sleep(3000)
|
|
58
55
|
|
|
59
56
|
const self = this;
|
|
60
57
|
|
|
61
58
|
if (req_data['is_collection']) {
|
|
62
|
-
var result = await this.
|
|
59
|
+
var result = await this.readCollections(socket, req_data, socketInfo);
|
|
63
60
|
return;
|
|
64
61
|
}
|
|
65
62
|
|
|
@@ -128,30 +125,21 @@ class CoCreateList {
|
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
async
|
|
128
|
+
async readCollections(socket, data, socketInfo) {
|
|
132
129
|
try {
|
|
133
|
-
|
|
134
|
-
const db = this.dbClient.db(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
name: item.name,
|
|
141
|
-
_id: __uuid,
|
|
142
|
-
id: __uuid,
|
|
143
|
-
});
|
|
144
|
-
})
|
|
145
|
-
return result;
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
this.wsManager.send(socket, 'readCollectionList', {...data, data: collections }, data['organization_id'], socketInfo);
|
|
130
|
+
const self = this;
|
|
131
|
+
const db = this.dbClient.db(data['organization_id']);
|
|
132
|
+
db.listCollections().toArray(function(error, result) {
|
|
133
|
+
if (!error && result && result.length > 0) {
|
|
134
|
+
self.wsManager.send(socket, 'readCollections', {...data, data: result }, data['organization_id'], socketInfo);
|
|
135
|
+
}
|
|
136
|
+
})
|
|
149
137
|
} catch(error) {
|
|
138
|
+
console.log('readCollections error', error);
|
|
150
139
|
this.wsManager.send(socket, 'ServerError', 'error', null, socketInfo);
|
|
151
140
|
}
|
|
152
141
|
}
|
|
153
142
|
|
|
154
|
-
|
|
155
143
|
/**
|
|
156
144
|
* function that make query from data
|
|
157
145
|
*
|