Super 🦸🏻
Super 🦸🏻
Explore posts from servers
KPCKevin Powell - Community
Created by Super 🦸🏻 on 5/27/2024 in #front-end
How can I show the select options at the bottom of the screen on a mobile device?
No description
10 replies
DTDrizzle Team
Created by Super 🦸🏻 on 6/13/2023 in #help
Do we have to add enums to the migration manually?
I have the following in the my schema:
const membershipRoleEnum = pgEnum('membership_role', [
'GUEST',
'MEMBER',
'PREMIUM_MEMBER',
'ADMIN',
'SUPER_ADMIN',
]);

export const groupMembers = pgTable(
'group_members',
{
id: serial('id').primaryKey(),
memberId: integer('member_id').references(() => users.id),
groupId: integer('group_id').references(() => groups.id),
role: membershipRoleEnum('role'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow(),
},
(table) => ({
memberIdx: index('member_idx').on(table.memberId),
groupIdx: index('group_idx').on(table.groupId),
})
);
const membershipRoleEnum = pgEnum('membership_role', [
'GUEST',
'MEMBER',
'PREMIUM_MEMBER',
'ADMIN',
'SUPER_ADMIN',
]);

export const groupMembers = pgTable(
'group_members',
{
id: serial('id').primaryKey(),
memberId: integer('member_id').references(() => users.id),
groupId: integer('group_id').references(() => groups.id),
role: membershipRoleEnum('role'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow(),
},
(table) => ({
memberIdx: index('member_idx').on(table.memberId),
groupIdx: index('group_idx').on(table.groupId),
})
);
Everything worked great except the enums did not get added to my sql file. I needed to manually add the following to my sql file:
CREATE TYPE membership_role AS ENUM (
'GUEST',
'MEMBER',
'PREMIUM_MEMBER',
'ADMIN',
'SUPER_ADMIN',
);
CREATE TYPE membership_role AS ENUM (
'GUEST',
'MEMBER',
'PREMIUM_MEMBER',
'ADMIN',
'SUPER_ADMIN',
);
Is that expected for now?
5 replies
DTDrizzle Team
Created by Super 🦸🏻 on 6/4/2023 in #help
Can someone help me understand these 2 examples using pool and client?
I'm reading through the docs and see that in the 2 Neon examples, they use a pool and client. From what I understand, pools support multiple requests and a client doesn't. The 2 questions I have are: - When would I want to close the pool or client? I would assume I would want to keep it open in production so that I wouldn't need to open the connection again. - Why would I use a client? Here are the examples I'm looking at in the docs: The docs show this example showing to close a pool (https://orm.drizzle.team/docs/installation-and-db-connection/postgresql/neon):
const pool = new Pool({ connectionString: env.DATABASE_URL });
const db = drizzle(pool)
const result = await db.select().from(...);
ctx.waitUntil(pool.end());
const pool = new Pool({ connectionString: env.DATABASE_URL });
const db = drizzle(pool)
const result = await db.select().from(...);
ctx.waitUntil(pool.end());
And the example provided uses a client https://github.com/drizzle-team/drizzle-orm/blob/main/examples/neon-cloudflare/src/index.ts
async function injectDB(request: Request, env: Env) {
request.client = new Client(env.DATABASE_URL);
request.db = drizzle(request.client);
}

router.get('/users', injectDB, async (req: Request, env: Env, ctx: ExecutionContext) => {
req.client.connect();
const result = await req.db.select().from(users);
ctx.waitUntil(req.client.end());
return json({ status: 'ok', result });
});
async function injectDB(request: Request, env: Env) {
request.client = new Client(env.DATABASE_URL);
request.db = drizzle(request.client);
}

router.get('/users', injectDB, async (req: Request, env: Env, ctx: ExecutionContext) => {
req.client.connect();
const result = await req.db.select().from(users);
ctx.waitUntil(req.client.end());
return json({ status: 'ok', result });
});
1 replies
KPCKevin Powell - Community
Created by Super 🦸🏻 on 4/18/2023 in #front-end
How to create restrict absolute positioned element from leaving grandparent's boundary?
27 replies
KPCKevin Powell - Community
Created by Super 🦸🏻 on 1/14/2023 in #front-end
How can I convert a span to an img
How can I convert a span to an img? -- Can I get some help with HTML? What would I need to do in order to make a span viewed the same way as an img while considering accessibility? I know it’s not semantically correct. Our current circumstances don’t load our img[src] in our screenshots so I was wondering if there are some attributes that I can add to a span with a background-image and have it viewed the same as an img (e.g. alt attribute)? I’m happy to read more into it if someone can point me where to look. My Googling has reached a dead end
7 replies