@cocreate/crud-server 1.20.1 → 1.20.3
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 +14 -0
- package/package.json +1 -1
- package/src/index.js +24 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.20.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.20.2...v1.20.3) (2023-05-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* return resolve ([eafc5e5](https://github.com/CoCreate-app/CoCreate-crud-server/commit/eafc5e59c59e3a3835a85b6e46a164f11fc6a80b))
|
|
7
|
+
|
|
8
|
+
## [1.20.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.20.1...v1.20.2) (2023-05-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* if platform org set dbUrl ([0dbafc9](https://github.com/CoCreate-app/CoCreate-crud-server/commit/0dbafc9b5ba77f3d16a5e14105a67e358ad697b8))
|
|
14
|
+
|
|
1
15
|
## [1.20.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.20.0...v1.20.1) (2023-04-11)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -98,29 +98,36 @@ class CoCreateCrudServer {
|
|
|
98
98
|
return new Promise(async (resolve) => {
|
|
99
99
|
try {
|
|
100
100
|
if (!data.organization_id)
|
|
101
|
-
resolve()
|
|
101
|
+
return resolve()
|
|
102
102
|
|
|
103
103
|
let dbUrl = this.databaseUrls.get(data.organization_id)
|
|
104
|
-
if (dbUrl ===
|
|
105
|
-
resolve()
|
|
104
|
+
if (dbUrl === false)
|
|
105
|
+
return resolve({dbUrl: false, error: 'database url could not be found'})
|
|
106
106
|
|
|
107
107
|
if (!dbUrl) {
|
|
108
|
-
|
|
109
|
-
dbUrl
|
|
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.
|
|
122
|
-
|
|
123
|
-
|
|
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
|
+
if (organization)
|
|
127
|
+
return resolve({dbUrl: false, error: 'database url could not be found'})
|
|
128
|
+
else
|
|
129
|
+
return resolve({organization: false, error: 'organization could not be found'})
|
|
130
|
+
}
|
|
124
131
|
}
|
|
125
132
|
}
|
|
126
133
|
|