@cocreate/organizations 1.2.3 → 1.2.4
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/client.js +0 -2
- package/src/server.js +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.2.4](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.2.3...v1.2.4) (2022-05-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* insert returns insertedId instead of [0]._id ([3a604ed](https://github.com/CoCreate-app/CoCreate-organizations/commit/3a604ed3759f3d607243b29b9ee568bb459ab40f))
|
|
7
|
+
|
|
1
8
|
## [1.2.3](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.2.2...v1.2.3) (2022-05-06)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
package/src/server.js
CHANGED
|
@@ -33,7 +33,7 @@ class CoCreateOrganization {
|
|
|
33
33
|
// Create new user in config db users collection
|
|
34
34
|
newOrgDb.insertOne({...result.ops[0], organization_id : newOrg_id}, function(error, result) {
|
|
35
35
|
if(!error && result){
|
|
36
|
-
const response = { ...data, document_id: result.
|
|
36
|
+
const response = { ...data, document_id: `${result.insertedId}`, data: result.ops[0]}
|
|
37
37
|
self.wsManager.send(socket, 'createOrgNew', response, data['organization_id']);
|
|
38
38
|
}
|
|
39
39
|
});
|
|
@@ -54,20 +54,23 @@ class CoCreateOrganization {
|
|
|
54
54
|
// create new org in config db organization collection
|
|
55
55
|
collection.insertOne({ ...data.data, organization_id: data.organization_id }, function(error, result) {
|
|
56
56
|
if(!error && result){
|
|
57
|
-
const orgId = result.
|
|
57
|
+
const orgId = `${result.insertedId}`
|
|
58
|
+
data.data['_id'] = result.insertedId
|
|
58
59
|
const anotherCollection = self.dbClient.db(orgId).collection(data['collection']);
|
|
59
60
|
// Create new org db and insert organization
|
|
60
|
-
anotherCollection.insertOne({...
|
|
61
|
+
anotherCollection.insertOne({...data.data, organization_id : orgId});
|
|
61
62
|
|
|
62
|
-
const response = { ...data, document_id:
|
|
63
|
+
const response = { ...data, document_id: orgId }
|
|
63
64
|
|
|
64
65
|
self.wsManager.send(socket, 'createOrg', response );
|
|
65
66
|
self.wsManager.broadcast(socket, data.namespace || data['organization_id'] , data.room, 'createDocument', response);
|
|
66
|
-
}
|
|
67
|
-
// add new org to masterDb
|
|
68
|
-
const masterOrgDb = self.dbClient.db(data.mdb).collection(data['collection']);
|
|
69
|
-
masterOrgDb.insertOne({...result.ops[0], organization_id : data['mdb']});
|
|
70
67
|
|
|
68
|
+
// add new org to platformDB
|
|
69
|
+
if (data.organization_id != process.env.organization_id) {
|
|
70
|
+
const platformDB = self.dbClient.db(process.env.organization_id).collection(data['collection']);
|
|
71
|
+
platformDB.insertOne({...data.data, organization_id: process.env.organization_id});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
71
74
|
});
|
|
72
75
|
}catch(error){
|
|
73
76
|
console.log('createDocument error', error);
|