marcbejar
marcbejar
Explore posts from servers
CDCloudflare Developers
Created by this_is_wayne on 9/4/2024 in #general-help
CLOUDFLARE ERROR
It happens to me, everytime I reboot the system I have to generate a new connection. Try running this commands win the cli warp-cli disconnect warp-cli registration delete warp-cli registration new warp-cli connect
11 replies
CDCloudflare Developers
Created by berkinovish on 5/31/2024 in #hyperdrive
While waiting for Cloudflare Tunnel
Is there an approximate date when this feature is expected to be released? I am about to release a product and if the feature release is close I will wait.
30 replies
DTDrizzle Team
Created by buckwheat on 8/20/2024 in #help
Disable selection in table creation
If you are running the query in the server I think it's quite safe to just "don't query" that column. Maybe you can take a look to getTableColums() function of Drizzle: https://orm.drizzle.team/learn/guides/include-or-exclude-columns If you are running the query in the client I think the best way to handle this is via permissions. But this depends on the DB architecture you are using. For example PostgreSQL have the Row Level Security RLS.
3 replies
DTDrizzle Team
Created by Δάρκζυ on 8/19/2024 in #help
How can I handle ID collisions
I would also use UUID. Yes, it takes more space but the chances of getting collision are absurdly low. In this case as the collision probability is so low I would just send an error to the client and let the user repeat the action. If you are using multiple PUT, DELETE; POST operations in the same server/API call make sure to use Drizzle transactions so you don't need to undo anything manually in case of collision.
10 replies
DTDrizzle Team
Created by marcbejar on 8/19/2024 in #help
Help with Join query
Makes sense, so I'm gonna make a query with two inner joins, so I have the tree tables information in the result. This results in something like:
[
{
"username": "test1",
"public": false,
"stripe": "test1",
"name": null,
"email": "user1@test1.com",
"role": 1
},
{
"username": "test1",
"public": false,
"stripe": "test1",
"name": null,
"email": "user2@test1.com",
"role": 0
}
]
[
{
"username": "test1",
"public": false,
"stripe": "test1",
"name": null,
"email": "user1@test1.com",
"role": 1
},
{
"username": "test1",
"public": false,
"stripe": "test1",
"name": null,
"email": "user2@test1.com",
"role": 0
}
]
Then what I understood is that i can use the map method to convert this array into an object with the common values and a new object "managers" that contains an array of the variable data. What I have done is the following:
const data = [...query result...]
let common_data = undefined;
const managers = [];

result.map((item, index) => {
if (index === 1) {
common_data = {
username: item.username,
public: item.public,
stripe: item.stripe,
};
}
managers.push({
name: item.name,
email: item.email,
role: item.role,
});
});

const final_data = {...settings, managers}
const data = [...query result...]
let common_data = undefined;
const managers = [];

result.map((item, index) => {
if (index === 1) {
common_data = {
username: item.username,
public: item.public,
stripe: item.stripe,
};
}
managers.push({
name: item.name,
email: item.email,
role: item.role,
});
});

const final_data = {...settings, managers}
And this results in:
{
"username": "test1",
"public": false,
"stripe": "test1",
"managers": [
{
"name": null,
"email": "user1@test1.com",
"role": 0
},
{
"name": null,
"email": "user2@test1.com",
"role": 1
}
],
}
{
"username": "test1",
"public": false,
"stripe": "test1",
"managers": [
{
"name": null,
"email": "user1@test1.com",
"role": 0
},
{
"name": null,
"email": "user2@test1.com",
"role": 1
}
],
}
That's the data that I need. Do you think this is the best approach or you think there is an optimal way doing this? Thanks a lot for your time.
3 replies
DTDrizzle Team
Created by marcbejar on 7/22/2024 in #help
Compostie primary key of a composite primary key
Thank you very much for the answer. I will keep coding like so. Thanks a lot!
3 replies