Skip to content

Need best practice of Generics API create multiple #7598

@alkiller22

Description

@alkiller22

According go-gorm/gorm.io#846, I try to using

_ = gorm.G[[]*UsersDB](db).Create(context.Background(), &[]*UsersDB{
	{UserID: "1"},
	{UserID: "2"},
})

_ = gorm.G[[]UsersDB](db).Create(context.Background(), &[]UsersDB{
	{UserID: "3"},
	{UserID: "4"},
})

The document you expected this should be explained

https://gorm.io/docs/create.html doesn't have any suggestions about Generics API's creating multiple records

Expected answer

Which one is preferred? G[[]T](db) or G[[]*T](db)? And why?
Can you put it in https://github.com/go-gorm/gorm/blob/master/tests/generics_test.go

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions