HotBBQSauce
HotBBQSauce
DTDrizzle Team
Created by Screw on 5/18/2024 in #help
Making a key in a object with jsonb unique
@Raphaël M (@rphlmr) ⚡ is right, however technically you can build your own sql query that will only allow the insertion of unique wallet objects based on a predefined key.
4 replies
DTDrizzle Team
Created by HotBBQSauce on 5/8/2024 in #help
I cant append new integers in a integer array
in the meanwhile i have updated the schema but still haven't found a solution, lets take the schema first as starting point i have updated the schema to look like this:
export const cryptoToken = pgTable("crypto_token", {
id: integer("id").primaryKey(),
rank: integer("rank"),
name: text("name").notNull(),
symbol: text("symbol").notNull(),
slug: text("slug").notNull(),
is_active: integer("is_active").notNull(),
first_historical_data: text("first_historical_data"),
last_historical_data: text("last_historical_data"),
});

type TokenPlatform = {
id: number;
contract_address: string;
};

export const platform = pgTable("platform", {
id: integer("id").unique().primaryKey(),
name: text("name"),
slug: text("slug"),
symbol: text("symbol"),
tokens: jsonb("tokens").$type<TokenPlatform[]>(),
});
export const cryptoToken = pgTable("crypto_token", {
id: integer("id").primaryKey(),
rank: integer("rank"),
name: text("name").notNull(),
symbol: text("symbol").notNull(),
slug: text("slug").notNull(),
is_active: integer("is_active").notNull(),
first_historical_data: text("first_historical_data"),
last_historical_data: text("last_historical_data"),
});

type TokenPlatform = {
id: number;
contract_address: string;
};

export const platform = pgTable("platform", {
id: integer("id").unique().primaryKey(),
name: text("name"),
slug: text("slug"),
symbol: text("symbol"),
tokens: jsonb("tokens").$type<TokenPlatform[]>(),
});
below is the actual return type of the API:
export type CMCCryptoMap = {
id: number;
rank: number;
name: string;
symbol: string;
slug: string;
is_active: number;
first_historical_data: string;
last_historical_data: string;
platform?: Platform;
};

export type Platform = {
id: number;
name: string;
symbol: string;
slug: string;
token_address: string;
tokenId: number;
};
export type CMCCryptoMap = {
id: number;
rank: number;
name: string;
symbol: string;
slug: string;
is_active: number;
first_historical_data: string;
last_historical_data: string;
platform?: Platform;
};

export type Platform = {
id: number;
name: string;
symbol: string;
slug: string;
token_address: string;
tokenId: number;
};
Oke now Platform really has alot of redundant data, basically al 8K rows could be wrapped into like 5-6 rows, im not sure what the best way would be to 'link' these together, pushing a single integer into a array that tells what token belongs to "this platform" was the easiest way i could come up with but it doesnt work.
4 replies
DTDrizzle Team
Created by yona on 12/15/2023 in #help
Documentation for PostgreSQL array type
Have you found anything about this yet? I have found a way to use a arrays when defined as custom type, however im not sure what the difference is between a json type and the custom type because they seem to translate to the same?
2 replies
DTDrizzle Team
Created by ethan on 3/8/2024 in #help
having issues with querying db
If only the drizzle query is not working i suppose it does work but you are using ilike incorrectly
15 replies
DTDrizzle Team
Created by ethan on 3/8/2024 in #help
having issues with querying db
Wait why are you using drizzle with pg and querying data using redis? This has nothing to do with drizzle your error i supose?
15 replies
DTDrizzle Team
Created by ethan on 3/8/2024 in #help
having issues with querying db
You havent shared the queries it might probaly be just an error in how its queried
15 replies
DTDrizzle Team
Created by ethan on 3/8/2024 in #help
having issues with querying db
Im not sure i cant spot where it could error have you made sure the database url is correct?
15 replies
DTDrizzle Team
Created by ethan on 3/8/2024 in #help
having issues with querying db
Remove resolve dirname or is that updated in the docs?
15 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
Oke cool✌🏼 i will give it a go later ill let u know the end solution! Maybe using elastic search or something will come in handy isnt what we are doing the intended use case?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
Or does to_tsquery alreadyhandle that?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
I see: where(sqlto_tsvector('simple', ${usersTable.name}) @@ to_tsquery('simple', ${searchParam})) So search param can take the regular string. do i still need to replaces whitespaces by % to have the order of the words in the column ignored when searching?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
Can i execute this functionality with drizzle sql feature or is this really something not supported by drizzle?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
Im not that familiar with the term full text search? Is this a built in sql feature or something?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
String.split(“%”)?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
Coming back to this, i have noticed that for example 256gb doesnt get picked up in the database where its stored as 256 GB. Should i just keep my regex code and map over the result which the delimiter as % instead of whitespace? And then append a trailing and leading %?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
Have read your explanation multiple times, i understand it now!!! Thanks for the help. I am wondering if this is sql injection safe handeld by drizzle or am i supposed to do that?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
@solo ?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
It does work thank you so much can you explain me what the difference is between the code you provided and what i had before so i can understand this for the next time when implementing myself
searchTerm = searchTerm.replace(
/(\d+)([a-zA-Z]+)|\s+/g,
function (match, p1, p2) {
return p1 ? "%" + p1 + "%" + p2 : "%";
}
);

const selectResult = await db
.select({
id: productsInformation.id,
name: productsInformation.name,
retailPrice: products.retailPrice,
inShopsPrice: products.inShopsPrice,
wholesalePrice: products.wholesalePrice,
})
.from(productsInformation)
.where(ilike(productsInformation.name, "%" + searchTerm + "%"))
.leftJoin(products, eq(products.sku, productsInformation.sku));
searchTerm = searchTerm.replace(
/(\d+)([a-zA-Z]+)|\s+/g,
function (match, p1, p2) {
return p1 ? "%" + p1 + "%" + p2 : "%";
}
);

const selectResult = await db
.select({
id: productsInformation.id,
name: productsInformation.name,
retailPrice: products.retailPrice,
inShopsPrice: products.inShopsPrice,
wholesalePrice: products.wholesalePrice,
})
.from(productsInformation)
.where(ilike(productsInformation.name, "%" + searchTerm + "%"))
.leftJoin(products, eq(products.sku, productsInformation.sku));
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
What do you mean by full text search capibilities?
30 replies
DTDrizzle Team
Created by HotBBQSauce on 2/18/2024 in #help
ilike drizzle postgress
Im always adding % between a series of numbers and letters if the consequent character differs basically from the previous ones
30 replies