为了账号安全,请及时绑定邮箱和手机立即绑定

我可以使用什么来代替DB。哪里

我可以使用什么来代替DB。哪里

Go
郎朗坤 2022-10-04 19:43:56
在Gorm中,我们可以使用从数据库中检查用户的数据以进行身份验证。但是我必须使用Go Fiber,所以我可以用什么来代替来检查用户是否存在于数据库中。DB.WhereDB.Wherevar user models.User     database.DB.Where("id = ?", claims.Issuer).(&user)
查看完整描述

2 回答

?
一只斗牛犬

TA贡献1784条经验 获得超2个赞

好吧,根据您的问题,gorm正在作为数据库和框架工作。

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

例如,您正在将MongoDB与GoFiber一起使用,因此它将使用以下方法:DB.Collection.FindOne()

在 Db.窗体中,用于查找数据库集合


查看完整回答
反对 回复 2022-10-04
?
小怪兽爱吃肉

TA贡献1852条经验 获得超1个赞

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


查看完整回答
反对 回复 2022-10-04
  • 2 回答
  • 0 关注
  • 110 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号