如何在Golang中使用MongoDB的$mod运算符?

huangapple go评论68阅读模式
英文:

How to use $mod operator from mongodb in Golang

问题

我检查了在Mongo中使用$mod运算符的用法,但是我找不到如何使用Golang进行相同查询的方法。

在Mongo中的用法:

{fieldName:{$mod:[24,0]}}

期望在Golang中的用法。

英文:

I checked the usage of $mod operator in mongo, but I could not find how to query the same using Golang.

Usage in mongo:

{fieldName:{$mod:[24,0]}}

Expecting the usage in Golang

答案1

得分: 1

你可以直接将其翻译为 bson.M 对象:

bson.M{"fieldName": bson.M{"$mod": []int{24, 0}}}
英文:

You can directly translate that to a bson.M object:

bson.M{"fieldName":bson.M{"$mod":[]int{24,0}}}

huangapple
  • 本文由 发表于 2023年2月14日 23:42:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75450141.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定