85
Moth girls rule (gregtech.eu)
submitted 3 weeks ago by [email protected] to c/[email protected]
46
submitted 3 weeks ago by [email protected] to c/[email protected]

I mean, it's just a specific collection of noises that somehow tingles our brains.

I assume it's because we are great at recognizing patterns, and music is just that - patterns.

48
Kitty and Blåhaj (gregtech.eu)
submitted 3 weeks ago by [email protected] to c/[email protected]
233
Kitty and Blåhaj (gregtech.eu)
submitted 3 weeks ago by [email protected] to c/[email protected]
218
submitted 4 weeks ago by [email protected] to c/[email protected]
121
submitted 1 month ago by [email protected] to c/[email protected]
19
submitted 1 month ago by [email protected] to c/[email protected]

Cross-posted from "What would be the best way to store the country of a user in SQL?" by @[email protected] in [email protected]


I use Gorm. This is the current code:

package main

import (
	"fmt"
	"log"

	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

type Env struct {
	DB     *gorm.DB
	Logger *log.Logger
}

type User struct {
	ID           uint
	Username     string
	Name         string
	Email        string
	PasswordHash string
	Country      string //should probably be a foreign key of another table
}

func initDB() {
	env := &Env{}
	db, err := gorm.Open(sqlite.Open("gorm.db"), &gorm.Config{})
	if err != nil {
		fmt.Printf("Error opening database: %v", err)
		return
	}
	env.DB = db
	env.DB.AutoMigrate(&User{})

}

func main() {
	initDB()
}

As you can see in the comment in the code, I assume the best way would be to have a table of countries and then assign each user to one via a foreign key. However, it seems a bit cumbersome to manually create a list of all countries. Is there a better way to do this?

12
submitted 1 month ago by [email protected] to c/[email protected]

I use Gorm. This is the current code:

package main

import (
	"fmt"
	"log"

	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

type Env struct {
	DB     *gorm.DB
	Logger *log.Logger
}

type User struct {
	ID           uint
	Username     string
	Name         string
	Email        string
	PasswordHash string
	Country      string //should probably be a foreign key of another table
}

func initDB() {
	env := &Env{}
	db, err := gorm.Open(sqlite.Open("gorm.db"), &gorm.Config{})
	if err != nil {
		fmt.Printf("Error opening database: %v", err)
		return
	}
	env.DB = db
	env.DB.AutoMigrate(&User{})

}

func main() {
	initDB()
}

As you can see in the comment in the code, I assume the best way would be to have a table of countries and then assign each user to one via a foreign key. However, it seems a bit cumbersome to manually create a list of all countries. Is there a better way to do this?

98
Lucky and Beri (files.catbox.moe)
submitted 1 month ago by [email protected] to c/[email protected]
133
/ᐠ。ꞈ。ᐟ\ (gregtech.eu)
submitted 1 month ago by [email protected] to c/[email protected]
94
submitted 1 month ago by [email protected] to c/[email protected]
169
Gladly :3 (gregtech.eu)
submitted 1 month ago by [email protected] to c/[email protected]
[-] [email protected] 50 points 1 month ago

This is an amazing explanation, and you also managed to keep it relatively short.

[-] [email protected] 48 points 2 months ago

This would mean I don't get to overengineer a button and a light :(

[-] [email protected] 49 points 2 months ago

Draw her programming with a kitty on the desk

[-] [email protected] 58 points 2 months ago* (last edited 2 months ago)

You can also put a backslash before a newline, like this

Line1\
Line2\
Line3

Looks like this:

Line1
Line2
Line3

Without the backslashes: Line1 Line2 Line3

With two newlines:

Line1

Line2

Line3

Also check out this Markdown tutorial , it's very helpful.

[-] [email protected] 50 points 3 months ago

They need to work on those 5G towers, they don't affect me TwT

[-] [email protected] 65 points 3 months ago

My grandpa transitioned, she's now my grandma

[-] [email protected] 54 points 4 months ago* (last edited 4 months ago)

Just keep using Firefox. Nothing in the code has changed, and if it does you can switch to forks. You all are evangelizing about how important FOSS is to prevent this exact scenario and yet you keep switching browsers for no need at all.

Note: I love Foss, I just think this is an overreaction

[-] [email protected] 65 points 5 months ago

This entire space appears to be larger than my apartment

view more: ‹ prev next ›

lena

0 post score
0 comment score
joined 5 months ago
MODERATOR OF