Clean documentation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
description: >-
|
||||
List of core shared components in Twake backend, available in
|
||||
List of core shared components in TDrive backend, available in
|
||||
src/core/platform/services
|
||||
---
|
||||
|
||||
@@ -8,7 +8,7 @@ description: >-
|
||||
|
||||
## **Database Technical Service**
|
||||
|
||||
Twake uses a custom ORM to work with both MongoDB and CassandraDB/ScyllaDB.
|
||||
TDrive uses a custom ORM to work with both MongoDB and CassandraDB/ScyllaDB.
|
||||
|
||||
[database-orm-platform-service](database-orm-platform-service.md)
|
||||
|
||||
@@ -106,7 +106,7 @@ Services annotated as described above automatically publish events to WebSockets
|
||||
```javascript
|
||||
const io = require("socket.io-client");
|
||||
|
||||
// Get a JWT token from the Twake API first
|
||||
// Get a JWT token from the TDrive API first
|
||||
const token =
|
||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOjEsImlhdCI6MTYwMzE5ODkzMn0.NvQoV9KeWuTNzRvzqbJ5uZCQ8Nmi2rCYQzcKk-WsJJ8";
|
||||
const socket = io.connect("http://localhost:3000", { path: "/socket" });
|
||||
@@ -148,7 +148,7 @@ socket.on("connect", () => {
|
||||
.emit("authenticate", { token })
|
||||
.on("authenticated", () => {
|
||||
// join the /channels room
|
||||
socket.emit("realtime:join", { name: "/channels", token: "twake" });
|
||||
socket.emit("realtime:join", { name: "/channels", token: "tdrive" });
|
||||
socket.on("realtime:join:error", (message) => {
|
||||
// will fire when join does not provide a valid token
|
||||
console.log("Error on join", message);
|
||||
@@ -229,7 +229,7 @@ socket.on("connect", () => {
|
||||
.emit("authenticate", { token })
|
||||
.on("authenticated", () => {
|
||||
// join the "/channels" room
|
||||
socket.emit("realtime:join", { name: "/channels", token: "twake" });
|
||||
socket.emit("realtime:join", { name: "/channels", token: "tdrive" });
|
||||
|
||||
// will only occur when an action occured on a resource
|
||||
// and if and only if the client joined the room
|
||||
|
||||
+14
-12
@@ -5,7 +5,10 @@
|
||||
A. Create an entity and put it anywhere in the code
|
||||
|
||||
```typescript
|
||||
import { Entity, Column } from "../../../core/platform/services/database/services/orm/decorators";
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
} from "../../../core/platform/services/database/services/orm/decorators";
|
||||
|
||||
@Entity("my_entity", {
|
||||
primaryKey: [["company_id"], "id"], //Primary key, see Cassandra documentation for more details
|
||||
@@ -45,25 +48,24 @@ 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 \(mongo or scylladb\) for development. Here is the process for each:
|
||||
|
||||
Scylla:
|
||||
|
||||
* on startup it creates the tables with the requested types, in this case twake\_boolean => tinyint on scylla side
|
||||
* on save entity it will convert the node type \(boolean\) to the good cql request: "{bool: false}" => "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 => true, 0 => false.
|
||||
- on startup it creates the tables with the requested types, in this case tdrive_boolean => tinyint on scylla side
|
||||
- on save entity it will convert the node type \(boolean\) to the good cql request: "{bool: false}" => "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 => true, 0 => false.
|
||||
|
||||
Mongo:
|
||||
|
||||
* on startup it does nothing \(mongo don't need to initialise columns
|
||||
* on save entity it will create a document, it means in mongo we just store json for each entity, there is no really a column concept.
|
||||
* on find entity we just get back the saved json and map it to the entity in node.
|
||||
- on startup it does nothing \(mongo don't need to initialise columns
|
||||
- on save entity it will create a document, it means in mongo we just store json for each entity, there is no really a column concept.
|
||||
- on find entity we just get back the saved json and map it to the entity in node.
|
||||
|
||||
Even if mongo just store json directly from mongo, we sometime do some changes to the data before to save in mongo, it will also be in the typeTransforms.ts file.
|
||||
|
||||
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 ''.
|
||||
* To fix all this just enforce the types in typeTransforms.ts for the twake\_boolean type.
|
||||
|
||||
- \(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 ''.
|
||||
- To fix all this just enforce the types in typeTransforms.ts for the tdrive_boolean type.
|
||||
|
||||
Reference in New Issue
Block a user