1

I want send a Mongo doc to users anytime it changes. Basically what I need is to listen for change events and then when a document is changed it gets passed it into a function that broadcasts to the correct people.

Can I listen for change events somehow? Is there a better DB to do this type of thing?

Thanks!

Community
  • 1
  • 1
fancy
  • 44,977
  • 57
  • 150
  • 228

3 Answers3

2

SERVER-124 may be implemented someday. In the meantime, you can hook into a replication process. Basically, you should do what legitimate replication clients do: tail the local.oplog collection. It contains all data modifications, you filter them, pick only interesting and broadcast to clients.

See here: http://www.mongodb.org/display/DOCS/Replication+Internals

Sergio Tulentsev
  • 219,187
  • 42
  • 361
  • 354
1

It's a planned feature. Vote for it here https://jira.mongodb.org/browse/SERVER-124

geakie
  • 1,418
  • 9
  • 9
0

You might be interested in mongo-oplog, which implements this in NodeJS by exploiting MongoDB's replication system.

Eric Martindale
  • 1,066
  • 1
  • 12
  • 25