我可以用什么代替 DB.Where

What can I use in place of DB.Where

在Gorm中我们可以使用DB.Where从数据库中查询用户的数据进行认证。但是我必须使用 Go Fiber,所以我可以用什么代替 DB.Where 来检查用户是否存在于数据库中。

var user models.User    
database.DB.Where("id = ?", claims.Issuer).(&user)

好吧,根据你的问题,gorm 既可以作为数据库也可以作为框架。

你可以使用 go fiber 作为框架,但是如果你想使用数据库,你不能使用来自 fiber 的数据库,而你必须使用一个数据库,你可以从中找到数据库中的数据集合。

例如,您在 GoFiber 中使用 MongoDB,因此它将使用 DB.Collection.FindOne()

的方法

表格中Db.Where用于查找数据库集合

Well, as per your question gorm is working as a database also as a framework.

you can use go fiber as a framework but if you want to use the database you cannot use the database from fiber instead you have to use a database from which you can find the collection of the data in the database.

For example, you are using MongoDB with GoFiber so it will use the method of DB.Collection.FindOne()

In form Db.Where is used to find the database collection