惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
有赞技术团队
有赞技术团队
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
Hugging Face - Blog
Hugging Face - Blog
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
罗磊的独立博客
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
B
Blog RSS Feed
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
V
Visual Studio Blog
B
Blog
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
L
LangChain Blog
D
Docker

Emil Burzo

GPS spoofing teleported me to Peru, mid-flight Running Claude Code dangerously (safely) Reverse engineering the Nest home/away API Tracking down an old OkHttp regression What does StackOverflow's personalized prediction data think of you? Cum se plătesc impozitele PFA prin BT24 Work-around for when keyserver.ubuntu.com is down Quick fix for CVE-2015-1328 Analiza parcului auto din România Setting up gitolite on Ubuntu 12.04 LTS
Creating a tailable cursor on MongoDB 3 with the Java dri...
2015-07-20 · via Emil Burzo

Having recently migrated Graticule’s backend to MongoDB 3 (which was surprisingly easy), I’ve noticed a lot of the methods used in the Java driver have been deprecated.

Most of them were easy to figure out, but tailable cursors presented a bit of a challenge.

I haven’t been able to find a clear-cut example online, so here’s one:

find(query).projection(fields).cursorType(CursorType.TailableAwait).iterator();

That code applies to the MongoCollection class.

CursorType is an enum and it has the following values:

  • Tailable
  • TailableAwait

Corresponding to the old DBCursor.addOption Bytes types:

  • Bytes.QUERYOPTION_TAILABLE
  • Bytes.QUERYOPTION_AWAITDATA

I hope that helps.

Happy coding!