ivan
ivan
DTDrizzle Team
Created by ivan on 8/5/2024 in #help
sqliteTable infer optional vs required fields
Perfect! That's exactly what I was missing. Thank you very much. Do I mark this thread as resolved now or something?
8 replies
DTDrizzle Team
Created by ivan on 8/5/2024 in #help
sqliteTable infer optional vs required fields
Seems that strict is unrelated to this since it is used for push as stated here: https://orm.drizzle.team/kit-docs/config-reference#strict Nevertheless this is my config:
import type { Config } from "drizzle-kit";

export default {
schema: "./src/app/schema.ts",
out: "./db/migrations",
dialect: "sqlite",
dbCredentials: {
url: "./data.db",
},
} satisfies Config;
import type { Config } from "drizzle-kit";

export default {
schema: "./src/app/schema.ts",
out: "./db/migrations",
dialect: "sqlite",
dbCredentials: {
url: "./data.db",
},
} satisfies Config;
Also here are my drizzle versions:
8 replies
DTDrizzle Team
Created by Charledeon on 8/4/2024 in #help
Constrain Numeric or Integer inputs
3. JSON data type is OK for this in general but since you are already using the relational database I would suggest to create separate table for SocialMediaLink and do a one to many relation between your user table and this table. See an example of one to many relation here https://hasura.io/learn/database/postgresql/core-concepts/6-postgresql-relationships/
3 replies
DTDrizzle Team
Created by Charledeon on 8/4/2024 in #help
Constrain Numeric or Integer inputs
Hi I am really new to drizzle but what you ask has nothing to do with the drizzle but with the database storage in general so I'll try to give you some ideas 🙂 1. you shouldn't be thinking about the phone numbers as number since you most likely don't want to perform any mathematical operations with them. The best storage for the phone numbers in my opinion is just simple text - which you can very easily constraint to 11 characters. Then you can add some phone number validation on top of it to be sure that user inputs only numbers (or even better + character followed by numbers). I suggest to use phone package (https://www.npmjs.com/package/phone) to validate E.164 format - this format works with most of the standardized SMS gateways etc. 2. generally you don't want to store the images within the database itself but rather store it on some sort of disk and then within the database only store the path to that file. In general you should use some object storage for storing the images like S3 from AWS (or basically any other cloud provider - all of them has some object storage). You can use some network disk, again AWS alternative is EFS. The last resort is to store images on the server disk (HDD or SSD) but this won't scale very well so it is a good idea to store images in some object storage (and maybe serve them through CDN) from start. If this sounds like overengineering and you just have very simple project you can store images in the database as BLOB which is suitable for binary data - https://www.postgresql.org/docs/current/datatype-binary.html - this might get out of hand when you will try to scale your application since every image request will go against your database and your database will grow exponentially once you have enough users. I don't recommend this.
3 replies
DTDrizzle Team
Created by ivan on 8/4/2024 in #help
How to get paginated result with the total count?
Hi @RiskyMH can you provide an example please?
6 replies