@cocreate/crud-server 1.20.1 → 1.20.2

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.20.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.20.1...v1.20.2) (2023-05-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * if platform org set dbUrl ([0dbafc9](https://github.com/CoCreate-app/CoCreate-crud-server/commit/0dbafc9b5ba77f3d16a5e14105a67e358ad697b8))
7
+
1
8
  ## [1.20.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.20.0...v1.20.1) (2023-04-11)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/crud-server",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
4
4
  "description": "CoCreate-crud-server",
5
5
  "keywords": [
6
6
  "cocreate-crud",
package/src/index.js CHANGED
@@ -105,22 +105,27 @@ class CoCreateCrudServer {
105
105
  resolve()
106
106
 
107
107
  if (!dbUrl) {
108
- let organization = await this.databases[this.database.name]['readDocument']({
109
- dbUrl: this.database.url[0],
110
- database: process.env.organization_id,
111
- collection: 'organizations',
112
- document: [{_id: data.organization_id}],
113
- organization_id: process.env.organization_id
114
- })
115
- if (organization && organization.document && organization.document[0])
116
- organization = organization.document[0]
117
- if (organization && organization.databases) {
118
- dbUrl = organization.databases
108
+ if (data.organization_id === process.env.organization_id) {
109
+ dbUrl = { [this.database.name]: this.database}
119
110
  this.databaseUrls.set(data.organization_id, dbUrl)
120
111
  } else {
121
- this.databaseUrls.set(data.organization_id, 'false')
122
- console.log('organization or dbUrl urls could not be found')
123
- resolve()
112
+ let organization = await this.databases[this.database.name]['readDocument']({
113
+ dbUrl: this.database.url[0],
114
+ database: process.env.organization_id,
115
+ collection: 'organizations',
116
+ document: [{_id: data.organization_id}],
117
+ organization_id: process.env.organization_id
118
+ })
119
+ if (organization && organization.document && organization.document[0])
120
+ organization = organization.document[0]
121
+ if (organization && organization.databases) {
122
+ dbUrl = organization.databases
123
+ this.databaseUrls.set(data.organization_id, dbUrl)
124
+ } else {
125
+ this.databaseUrls.set(data.organization_id, 'false')
126
+ console.log('organization or dbUrl urls could not be found')
127
+ resolve()
128
+ }
124
129
  }
125
130
  }
126
131