Sabbir Hossain Shuvo
Sabbir Hossain Shuvo
Explore posts from servers
DDeno
Created by Sabbir Hossain Shuvo on 10/13/2024 in #help
[bug ✨] Cannot find module (in vs code)
Thank you so much, I did 🙂
3 replies
DTDrizzle Team
Created by Sabbir Hossain Shuvo on 3/10/2024 in #help
Filter from array
@Turso @Neon
2 replies
DTDrizzle Team
Created by 균어 on 3/5/2024 in #help
How to get findMany with count?
Also if you want you can check out this website to get live demo. https://finddevs.vercel.app/
9 replies
DTDrizzle Team
Created by 균어 on 3/5/2024 in #help
How to get findMany with count?
here is an example that I already did.
const [lengths, profiles] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(users),
searchParams
? db
.select()
.from(users)
.where(
or(
ilike(users.name, `%${searchParams}%`),
ilike(users.location, `%${searchParams}%`),
),
)
.limit(itemPerPage)
.offset(offset)
: db
.select()
.from(users)
.orderBy(sql.raw("RANDOM()"))
.limit(itemPerPage)
.offset(offset),
]);
const count = lengths[0].count; // this will b e
const [lengths, profiles] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(users),
searchParams
? db
.select()
.from(users)
.where(
or(
ilike(users.name, `%${searchParams}%`),
ilike(users.location, `%${searchParams}%`),
),
)
.limit(itemPerPage)
.offset(offset)
: db
.select()
.from(users)
.orderBy(sql.raw("RANDOM()"))
.limit(itemPerPage)
.offset(offset),
]);
const count = lengths[0].count; // this will b e
9 replies
DTDrizzle Team
Created by Sabbir Hossain Shuvo on 1/25/2024 in #help
Filter (Where)
@Angelelz thanks let me try with this.. another question boss 😄 can you tell me how can i also filter from array likes we have a array of fndsnames
let fndsName = ["sabbir", "shuvo", "robin", "alex"];
let fndsName = ["sabbir", "shuvo", "robin", "alex"];
so, i can access that array using users.fndsName
7 replies
DTDrizzle Team
Created by JT on 3/18/2023 in #help
What is the type for an .orderBy() parameter
no need this I got solution,
orderBy(sql.raw("RANDOM()"))
orderBy(sql.raw("RANDOM()"))
15 replies
DTDrizzle Team
Created by JT on 3/18/2023 in #help
What is the type for an .orderBy() parameter
how can I order row as random??
15 replies
DTDrizzle Team
Created by Sabbir Hossain Shuvo on 1/25/2024 in #help
Filter (Where)
currently i'm using this way,, but I wish there are have any way to do this.
const [lengths, profiles] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(users),
searchParams
? db
.select()
.from(users)
.where(
or(
ilike(users.name, `%${searchParams}%`),
ilike(users.location, `%${searchParams}%`)
)
)
.limit(itemPerPage)
.offset(offset)
: db.select().from(users).limit(itemPerPage).offset(offset),
]);
const [lengths, profiles] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(users),
searchParams
? db
.select()
.from(users)
.where(
or(
ilike(users.name, `%${searchParams}%`),
ilike(users.location, `%${searchParams}%`)
)
)
.limit(itemPerPage)
.offset(offset)
: db.select().from(users).limit(itemPerPage).offset(offset),
]);
7 replies
DTDrizzle Team
Created by Sabbir Hossain Shuvo on 1/25/2024 in #help
Filter (Where)
full code is here..
import React from "react";
import { db } from "@/database";
import { users } from "@/schemas";
import ProfileCard from "./ProfileCard";
import Paginations from "../pagination/Paginations";
import { ilike, or, sql } from "drizzle-orm";
import Notfound from "../shared/Notfound";
import Search from "../shared/search/Search";

type Props = {
page: string;
searchParams?: string;
};

const ProfileGrid = async ({ page, searchParams }: Props) => {
const currentPage = parseInt(page); // like 1
const itemPerPage = 5; // we want to show 5 item in per pages
const offset = (currentPage - 1) * itemPerPage; // (1 - 1) * 3 = 0

const [lengths, profiles] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(users),
db
.select()
.from(users)
.where(
or(
ilike(users.name, `%${searchParams}%`),
ilike(users.location, `%${searchParams}%`)
)
)
.limit(itemPerPage)
.offset(offset),
]);
const count = lengths[0].count;

return (
<div className="mt-32 mb-8 border-t-orange-500 ml-[20rem] px-6 overflow-y-scroll">
<Search />
<div className="flex-center flex-col gap-3">
{count <= 0 ? (
<Notfound />
) : (
profiles.map((item, index: number) => (
<ProfileCard
key={index}
role={item.role}
description={item.description}
location={item.location}
name={item.name}
portfolio={item.portfolio as string}
skill={item.skills}
profileImage={item.profileImage as string}
social={item.social as any}
/>
))
)}
</div>
<Paginations
hasNextPage={currentPage < Math.ceil(count / itemPerPage)}
hasPrevPage={currentPage !== 1}
/>
</div>
);
};

export default ProfileGrid;
import React from "react";
import { db } from "@/database";
import { users } from "@/schemas";
import ProfileCard from "./ProfileCard";
import Paginations from "../pagination/Paginations";
import { ilike, or, sql } from "drizzle-orm";
import Notfound from "../shared/Notfound";
import Search from "../shared/search/Search";

type Props = {
page: string;
searchParams?: string;
};

const ProfileGrid = async ({ page, searchParams }: Props) => {
const currentPage = parseInt(page); // like 1
const itemPerPage = 5; // we want to show 5 item in per pages
const offset = (currentPage - 1) * itemPerPage; // (1 - 1) * 3 = 0

const [lengths, profiles] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(users),
db
.select()
.from(users)
.where(
or(
ilike(users.name, `%${searchParams}%`),
ilike(users.location, `%${searchParams}%`)
)
)
.limit(itemPerPage)
.offset(offset),
]);
const count = lengths[0].count;

return (
<div className="mt-32 mb-8 border-t-orange-500 ml-[20rem] px-6 overflow-y-scroll">
<Search />
<div className="flex-center flex-col gap-3">
{count <= 0 ? (
<Notfound />
) : (
profiles.map((item, index: number) => (
<ProfileCard
key={index}
role={item.role}
description={item.description}
location={item.location}
name={item.name}
portfolio={item.portfolio as string}
skill={item.skills}
profileImage={item.profileImage as string}
social={item.social as any}
/>
))
)}
</div>
<Paginations
hasNextPage={currentPage < Math.ceil(count / itemPerPage)}
hasPrevPage={currentPage !== 1}
/>
</div>
);
};

export default ProfileGrid;
7 replies
TTCTheo's Typesafe Cult
Created by Sabbir Hossain Shuvo on 1/24/2024 in #questions
Uploadthing: skip uploading the same file the second time
I don't want this,,, same files is too many time... 😢
3 replies
DTDrizzle Team
Created by Sabbir Hossain Shuvo on 1/20/2024 in #help
Drizzle Relations
@Angelelz should i share my github repo??
6 replies