lena

joined 4 months ago
MODERATOR OF
 
[–] [email protected] 3 points 1 day ago

Yeah I recommend removing it, as the technical part of it is not relevant anymore. You can add a new one if I get around to writing it.

[–] [email protected] 3 points 1 day ago (2 children)

Dev here, just a heads up that the blog post is outdated

[–] [email protected] 1 points 2 days ago

from my brief time hosting snac, iirc it stores data in JSON files

 
[–] [email protected] 9 points 2 days ago (2 children)

https://codeberg.org/grunfink/snac2 and https://gotosocial.org/

The snac2 dev made it using only openssl and curl libraries. It doesn't even use a proper database, so it's very lightweight.

Gotosocial is basically mastodon but easier to set up on the server and lighter on resource usage.

[–] [email protected] 2 points 2 days ago (1 children)

I'll Go do it myself

[–] [email protected] 15 points 3 days ago (3 children)

Use Rust for memory safety

[–] [email protected] 5 points 4 days ago (1 children)

My condolences

[–] [email protected] 41 points 4 days ago (2 children)
[–] [email protected] 1 points 4 days ago (1 children)

Stuff hosted by cloudflare is not the whole internet

[–] [email protected] 5 points 4 days ago* (last edited 4 days ago)
[–] [email protected] 8 points 4 days ago (5 children)
[–] [email protected] -1 points 4 days ago (4 children)

Sooooo I copy paste every single country code and put it in a table?

 

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?

 

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?

97
Lucky and Beri (files.catbox.moe)
 
 
346
Oh noes! (gregtech.eu)
 
620
submitted 1 week ago* (last edited 1 week ago) by [email protected] to c/[email protected]
 

https://www.githubstatus.com/

Edit: seems like they fixed it, it works for me

 
 
view more: next ›