有没有一种替代 org.bson.types.ObjectId 的方法,而不需要整个 mongodb 驱动程序?

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

Is there an alternative to org.bson.types.ObjectId that doesn't require the entire mongodb driver?

问题

只是为了背景,出于依赖原因,我必须从项目中移除 MongoDB(请勿对 MongoDB 不敬!)。我已经在将所有部件替换为 PostgreSQL 等效部件方面进展良好,但我在 org.bson.types.ObjectId 部分遇到了一些困难 - 出于一致性的原因,我不想完全替换它们,但我又不愿意仅为此保留整个 org.mongodb:mongo-java-driver:3.12.5 依赖。

是否有其他方法来生成等效的 ObjectIDs?或者是否可以单独导入 bson 类型呢?

英文:

So just for background I have to drop mongodb from a project (for dependency reasons, no disrespect to MongoDB!). I'm well into replacing all of the pieces with PostgreSQL equivalents but I'm a little bit stuck on org.bson.types.ObjectId - I don't want to replace those completely, for consistency reasons but I'm loathe to keep the whole org.mongodb:mongo-java-driver:3.12.5 dependency in my project just for that.

Is there some other way to generate equivalent ObjectIDs? Or can I import just the bson types separately somehow?

答案1

得分: 1

> 有其他方法可以生成等效的ObjectIDs吗?

您可以自己实现ObjectId规范,它相当简单。

英文:

> Is there some other way to generate equivalent ObjectIDs?

You can implement the ObjectId spec yourself, it is pretty small.

答案2

得分: 0

这似乎有效(gradle):
compile group: 'org.mongodb', name: 'bson', version: '3.12.5'

英文:

This seems to work (gradle):
compile group: 'org.mongodb', name: 'bson', version: '3.12.5'

huangapple
  • 本文由 发表于 2020年8月24日 19:34:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/63560224.html
匿名

发表评论

匿名网友

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

确定