@cocreate/organizations 1.3.2 → 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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.4.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.3.2...v1.4.0) (2022-05-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * deleteOrg will delete db and org from from platformDB ([0fcb1bc](https://github.com/CoCreate-app/CoCreate-organizations/commit/0fcb1bc2ecdbb1948733c240ce7adfaceaa2b5e6))
7
+
1
8
  ## [1.3.2](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.3.1...v1.3.2) (2022-05-23)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/organizations",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "A simple organizations component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "organizations",
package/src/server.js CHANGED
@@ -52,8 +52,33 @@ class CoCreateOrganization {
52
52
  async deleteOrg(socket, data, socketInfo) {
53
53
  const self = this;
54
54
  if(!data.data) return;
55
+ const organization_id = data.data.organization_id
56
+ if(!organization_id || organization_id == process.env.organization_id) return;
57
+
55
58
  try{
56
- // ToDo: Delete DB and delete org and user from masterDB
59
+ const db = this.dbClient.db(organization_id);
60
+ db.dropDatabase().then(response => {
61
+ if (response === true){
62
+ console.log('deleteOrg response', response)
63
+ }
64
+
65
+ // delete org from platformDB
66
+ // if (organization_id != process.env.organization_id) {
67
+ const platformDB = self.dbClient.db(process.env.organization_id).collection(data['collection']);
68
+ const query = {
69
+ "_id": new ObjectId(organization_id)
70
+ };
71
+
72
+ platformDB.deleteOne(query, function(error, result) {
73
+ if (!error) {
74
+ let response = { ...data }
75
+ self.broadcast(socket, 'deleteDocument', response, socketInfo)
76
+ } else {
77
+ self.wsManager.send(socket, 'ServerError', error, socketInfo);
78
+ }
79
+ })
80
+ // }
81
+ })
57
82
  }catch(error){
58
83
  console.log('deleteOrg error', error);
59
84
  }