Rami
Rami
TtRPC
Created by Rami on 3/23/2024 in #❓-help
Can I create custom terminating links?
It works but I can't really rely on it when there's a large amounts of data to cache. I also wanna be able to make insertions in offline mode. Think a to-do list app on your phone. So I was thinking I could have an sqlite DB stored locally. So my question is, how can I run these client-side DB operations with tRPC? Links seemed like a possible option, but also this https://discord.com/channels/867764511159091230/1221200250879082647 can also be an option if it's possible... Is it?
6 replies
TtRPC
Created by Rami on 3/23/2024 in #❓-help
Can I create custom terminating links?
@BeBoRE Sorry for the ping but I'd really appreciate your opinion on this
6 replies
DTDrizzle Team
Created by arush on 3/8/2024 in #help
drizzle-studio doesn't see pgView materialized views
I recommend building and testing out the SQL query for whatever you want the view to be inside drizzle studio, so for example if I want to test out the previous materialized view, I would run:
SELECT
date_trunc('day', created_at)::DATE AS date,
COUNT(DISTINCT id) AS count
FROM
claims
GROUP BY
date_trunc('day', created_at)
ORDER BY
date_trunc('day', created_at);
SELECT
date_trunc('day', created_at)::DATE AS date,
COUNT(DISTINCT id) AS count
FROM
claims
GROUP BY
date_trunc('day', created_at)
ORDER BY
date_trunc('day', created_at);
In there to see if it gives me what I want
7 replies
DTDrizzle Team
Created by arush on 3/8/2024 in #help
drizzle-studio doesn't see pgView materialized views
P.S I'm just someone who started working with drizzle like 2 month back and this is my workflow with creating materialized views
7 replies
DTDrizzle Team
Created by arush on 3/8/2024 in #help
drizzle-studio doesn't see pgView materialized views
Also for the SQL query that creates the materialized views, this is an example:
DO
$$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM pg_matviews
WHERE matviewname = 'claim_assets_view'
) THEN
CREATE MATERIALIZED VIEW claim_assets_view AS
SELECT
date_trunc('day', created_at)::DATE AS date,
COUNT(DISTINCT id) AS count
FROM
claims
GROUP BY
date_trunc('day', created_at)
ORDER BY
date_trunc('day', created_at);
END IF;
END $$;
DO
$$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM pg_matviews
WHERE matviewname = 'claim_assets_view'
) THEN
CREATE MATERIALIZED VIEW claim_assets_view AS
SELECT
date_trunc('day', created_at)::DATE AS date,
COUNT(DISTINCT id) AS count
FROM
claims
GROUP BY
date_trunc('day', created_at)
ORDER BY
date_trunc('day', created_at);
END IF;
END $$;
7 replies
DTDrizzle Team
Created by arush on 3/8/2024 in #help
drizzle-studio doesn't see pgView materialized views
Drizzle doesn't yet support views. You will have to manually write an SQL script that would create that view. Then create a custom migration by running: drizzle-kit generate:pg --custom. Insert that SQL script into that generated migration file. Then run your migrations to update your database to have that view. This is my migration.ts file if you haven't made one:
import { migrate } from "drizzle-orm/node-postgres/migrator";
import { createConnection } from "../utils";

async function runMigrations() {
const { db, pg } = await createConnection();

try {
await migrate(db, { migrationsFolder: "./migrations" });
} finally {
await pg.end();
}
}

runMigrations().catch((error) => {
console.error(error);
process.exit(1); // eslint-disable-line unicorn/no-process-exit
});
import { migrate } from "drizzle-orm/node-postgres/migrator";
import { createConnection } from "../utils";

async function runMigrations() {
const { db, pg } = await createConnection();

try {
await migrate(db, { migrationsFolder: "./migrations" });
} finally {
await pg.end();
}
}

runMigrations().catch((error) => {
console.error(error);
process.exit(1); // eslint-disable-line unicorn/no-process-exit
});
Check this page for more info: https://orm.drizzle.team/docs/migrations
7 replies
DTDrizzle Team
Created by arush on 3/8/2024 in #help
drizzle-studio doesn't see pgView materialized views
7 replies
DTDrizzle Team
Created by MAnd on 12/13/2023 in #help
How to use a view after creating it?
Yeah makes sense, appreciate the help😊
9 replies
DTDrizzle Team
Created by MAnd on 12/13/2023 in #help
How to use a view after creating it?
@nk Did you not have to manually create the materialized view outside of drizzle? It didn't work for me until I manually created the view with SQL. From what I understand drizzle-kit doesn't yet generate the views for us, so how else did you create the view if not manually?
9 replies
DTDrizzle Team
Created by Cyber Grandma on 1/22/2024 in #help
Drizzle-kit not detecting views ?
seems like drizzle-kit is not open source, and that's where the feature needs to be added, right?
14 replies
DTDrizzle Team
Created by Cyber Grandma on 1/22/2024 in #help
Drizzle-kit not detecting views ?
14 replies
DTDrizzle Team
Created by MAnd on 12/13/2023 in #help
How to use a view after creating it?
@Rafael Rossi await db.select().from(View) doesn't work for me. It is saying that relation "pg_view" does not exist. What is going on? I ran drizzle-kit push:pg and generate, am I missing something?
9 replies
DTDrizzle Team
Created by Cyber Grandma on 1/22/2024 in #help
Drizzle-kit not detecting views ?
@Cyber Grandma if you help me with that I can help you with centering a div
14 replies
DTDrizzle Team
Created by Cyber Grandma on 1/22/2024 in #help
Drizzle-kit not detecting views ?
how do you actually query the view? await db.select().from(View) doesn't work for me. It is saying that relation "pg_view" does not exist. What is going on?
14 replies