@cocreate/crud-server
Advanced tools
Comparing version 1.26.0 to 1.27.0
@@ -0,1 +1,15 @@ | ||
# [1.27.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.26.0...v1.27.0) (2023-08-21) | ||
### Bug Fixes | ||
* /dist/CoCreate.js updated to https://CoCreate.app/dist/CoCreate.js ([1f82f69](https://github.com/CoCreate-app/CoCreate-crud-server/commit/1f82f6921aa6dc39410263eea7e4ee4b535d7039)) | ||
* replace cdn with /dist ([7ad2004](https://github.com/CoCreate-app/CoCreate-crud-server/commit/7ad20046820f19a12917edd13b379da652ac391b)) | ||
* update file uploader ([f6000d9](https://github.com/CoCreate-app/CoCreate-crud-server/commit/f6000d9e0ed2569d35d8cd7f81b7dece04446c25)) | ||
### Features | ||
* handling stats from multiple storages. ([5d06d16](https://github.com/CoCreate-app/CoCreate-crud-server/commit/5d06d169ce12ed4000e529f54fc3404380997f57)) | ||
# [1.26.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.25.0...v1.26.0) (2023-08-17) | ||
@@ -2,0 +16,0 @@ |
{ | ||
"name": "@cocreate/crud-server", | ||
"version": "1.26.0", | ||
"version": "1.27.0", | ||
"description": "CoCreate-crud-server", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -30,3 +30,3 @@ 'use strict'; | ||
let dbUrl | ||
let storageUrl | ||
if (this.config.storage) { | ||
@@ -36,3 +36,3 @@ if (typeof this.config.storage === 'string') | ||
let defaultStorage = Object.keys(this.config.storage) | ||
dbUrl = this.config.storage[defaultStorage[0]].url | ||
storageUrl = this.config.storage[defaultStorage[0]].url | ||
} | ||
@@ -42,5 +42,5 @@ | ||
console.log('Could not find the organization_id') | ||
if (!dbUrl) | ||
if (!storageUrl) | ||
console.log('Could not find a url in your storage object') | ||
if (!dbUrl && !this.config.organization_id) | ||
if (!storageUrl && !this.config.organization_id) | ||
process.exit() | ||
@@ -88,11 +88,11 @@ | ||
let storage = this.storages.get(data.organization_id) | ||
if (storage === false) | ||
let storages = this.storages.get(data.organization_id) | ||
if (storages === false) | ||
return resolve({ storage: false, error: 'A storage or database could not be found' }) | ||
if (!storage) { | ||
if (!storages) { | ||
if (data.organization_id === this.config.organization_id) { | ||
storage = this.config.storage | ||
if (storage) | ||
this.storages.set(data.organization_id, storage) | ||
storages = this.config.storage | ||
if (storages) | ||
this.storages.set(data.organization_id, storages) | ||
} else { | ||
@@ -109,4 +109,4 @@ let organization = await this.send({ | ||
if (organization && organization.storage) { | ||
storage = organization.storage | ||
this.storages.set(data.organization_id, storage) | ||
storages = organization.storage | ||
this.storages.set(data.organization_id, storages) | ||
} else { | ||
@@ -125,2 +125,3 @@ this.storages.set(data.organization_id, false) | ||
// TODO: manage error handling if if no method defined | ||
if (data.method.startsWith('update') && data.upsert != false) | ||
@@ -166,3 +167,3 @@ data.upsert = true | ||
if (!data.storage || !data.storage.length) { | ||
data.storage = [Object.keys(storage)[0]] | ||
data.storage = [Object.keys(storages)[0]] | ||
} else if (!Array.isArray(data.storage)) | ||
@@ -172,14 +173,17 @@ data.storage = [data.storage] | ||
for (let i = 0; i < data.storage.length; i++) { | ||
if (storage && storage[data.storage[i]]) { | ||
let db = storage[data.storage[i]] | ||
if (storages && storages[data.storage[i]]) { | ||
let storage = storages[data.storage[i]] | ||
if (db.provider && this.databases[db.provider]) { | ||
if (!Array.isArray(db.url)) | ||
db.url = [db.url] | ||
for (let i = 0; i < db.url.length; i++) { | ||
data['dbUrl'] = db.url[i] | ||
data = await this.databases[db.provider][action](data) | ||
if (storage.provider && this.databases[storage.provider]) { | ||
if (!Array.isArray(storage.url)) | ||
storage.url = [storage.url] | ||
for (let i = 0; i < storage.url.length; i++) { | ||
data['storageName'] = data.storage[i] | ||
data['storageUrl'] = storage.url[i] | ||
data = await this.databases[storage.provider][action](data) | ||
} | ||
if (data.filter) { | ||
if (!data.type) | ||
data.type = data.method.split('.').pop() | ||
if (data.filter.sort && data.filter.sort.length) | ||
@@ -197,3 +201,5 @@ data[data.type] = sortData(array, data.filter.sort) | ||
delete data.dbUrl | ||
delete data.storageUrl | ||
delete data.storageName | ||
if (socket) { | ||
@@ -200,0 +206,0 @@ if (data.organization_id === this.config.organization_id && socket.config.organization_id !== data.organization_id) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
111119
249