📝Updated documentation for the backend services

This commit is contained in:
Anton SHEPILOV
2024-05-28 16:46:01 +02:00
committed by Anton Shepilov
parent 904b767382
commit 3cf164787f
26 changed files with 193 additions and 248 deletions
@@ -7,7 +7,11 @@ description: >-
# Platform/Technical services
## **Database Technical Service**
<!-- TODO[NOT UP TO DATE] -->
Twake Drive uses a custom ORM to work with both MongoDB and CassandraDB/ScyllaDB.
Twake Drive uses a custom ORM to work with both MongoDB and PostgreSQL.
[database-orm-platform-service](database-orm-platform-service.md)
::: info
This paragraph is not ready yet, you can contribute to this documentation on our [Github](https://github.com/linagora/twake-drive/issues/545)!
:::
@@ -48,13 +48,13 @@ await repository.remove({company_id: "", id: ""});
#### I set a column to a type but I get an other type on code. Why for two identical definitions it created fields of different types?
It depends on what database you use \(mongo or scylladb\) for development. Here is the process for each:
It depends on what database you use (MongoDB or PostgreSQL) for development. Here is the process for each:
Scylla:
PostgreSQL:
- on startup it creates the tables with the requested types, in this case tdrive_boolean =&gt; tinyint on scylla side
- on save entity it will convert the node type \(boolean\) to the good cql request: "{bool: false}" =&gt; "SET bool = 0", it happens in the transformValueToDbString method
- on find entity it will convert the database raw value \(a tinyint\) to the nodejs type \(boolean\): 1 =&gt; true, 0 =&gt; false.
- on startup it creates the tables with the requested types, in this case tdrive_boolean =&gt; boolean on PostgreSQL side
- on save entity it will convert the node type \(boolean\) to the good sql request: "{bool: false}" =&gt; "SET bool = false", it happens in the transformValueToDbString method
- on find entity it will convert the database raw value \(a boolean\) to the nodejs type \(boolean\)
Mongo:
@@ -67,5 +67,5 @@ Mongo:
So what could have happened in you case ?
- \(1\) if you use mongodb and we did not enforce the type before to save to mongo, then maybe you used a string instead of a boolean at some point in time while working and mongo just saved it as it was \(without checking the requested type on entity\)
- \(2\) other possibility is that we incorrectly get the information from the database on the typeTransforms.ts file, from cassandra for instance I think we don't convert tinyint back to clean boolean, so you could get 0 and 1 instead of false and true. And maybe instead of 0 and 1 sometime undefined values can convert to ''.
- \(2\) other possibility is that we incorrectly get the information from the database on the typeTransforms.ts file, from PostgreSQL for instance I think we don't convert tinyint back to clean boolean, so you could get 0 and 1 instead of false and true. And maybe instead of 0 and 1 sometime undefined values can convert to ''.
- To fix all this just enforce the types in typeTransforms.ts for the tdrive_boolean type.