I have a posts table with few columns including a liked_by column which’s type is an int array. As I can’t post the table here I’ll post a single post’s JSON structure which comes as below I’m trying to send posts in the order they are liked (Most Liked Posts). Which should order the posts according to the number of
Tag: go-gorm
In go – gorm “mssql: Invalid column name ‘id’
This is my model in go } and this is my repo(that retrieve data from database): } On “http” I write this code with echo When I cal my ReadAll record rerieve data completly , it’s mean I conected to database currectly,But whene I try get data by “id” got an error that : mssql: Invalid column name ‘id’. Whet
Is it possible to omit FieldID in struct when using gorm?
Looking at an example from their documentation: CompanyID field seems rather redundant. Is it possible to get rid of it using some tags on Company field instead? Answer Changing User definition like this did the trick:
Doing 4 way filter based on 3 tables using GORM
I’ve been trying to achieve a 4 way to join/filter based on 4 tables “Offers”, “UserPaymentMethods” and a junction table “OffersUserPaymentMethods” defined as below; So I want to filter “offers” based on payment_method_id because offer_id lives in offers_user_payment_methods which makes it a bit tricky. Front-end will send payment_method_id and I need to filter offers based on the payment_method_id that’s it.
Sort records with an associated field
I want to order records with associated records in GORM V2. I have two structs: type Client struct { gorm.Model UUID uuid.UUID `gorm:”type:uuid”` ClientProfile …
How to Fetch specific number of characters from a string using gorm?
I am using SQLite, if I have a text post or an article that is a 400 character string for example, I want to extract only the first 100 character from it to be used in the front-end. In line 4 i extracted the latest 5 posts from the db, but i want to limit the body of the post
How to filter table with entity from other tables related by many to many relationship using GORM?
I have Product table which is connected with the other two tables Categorie & AttributeValue using many to many relationships. I am using GORM as an ORM. go struct for those tables are like bellow….
How to set where clause dynamically in GORM
I will receive a map[string][]string. For each key in the map i want to add where clause like bellow. inFilter := map[string][]string{“product_id”: []string{“3”, “69”}} for key, value := range …