Storing Images
Hi everyone, I just want to know what is the best way to store images according to these info about the system I'm building.
- a user needs to have a profile picture.
- I need to store a number of images for each user.
- a user can create a post, and the post may have an image.
- The hero section of the app may have a dynamic image that the admin can change.
- I need to store a number of images for each activity 'activity is a table to hold some info about an activity' created.
7 Replies
Hello Ans. You shouldn't store images (blobs) in a relational database, what you want to do is upload them to something like S3 and store the references/links to that in the DB
you can use uploadthing https://uploadthing.com/
You are right, I already doing that, I'm asking about the best approach to properly store images for multiple things, like persons images, posts images, activites images, should I put them all in one talbe, or each one needs it's own table
As a second question
I get this error
how to properly set the
updatedAt
to be automatically updated when updaing the documnet in the database.
thanks for sharingOh, this TypeError is a known issue that will be addressed soon
As for this, every project has different needs. This is more of a general DB question rather than Drizzle specific so you could do some research online about how others handle what you're describing.
I personally store the reference of the images into the same table, so for example, if I have a
post
table, I'll have a field like imageLink
/imageMetadata
/imageRef
Thanks for your help
I'm getting this error as well! same syntax and with postgres. To get by it, im just diong doing
() => new Date()
which seems to work, though would prefer to let the DB do the work with SQLYeah, using the DB handle it is better. We'll get to patching this soon