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
  • 48,619
  • 62
  • 153
  • 231

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
  • 226,338
  • 43
  • 373
  • 367
1

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

geakie
  • 1,458
  • 9
  • 9
0

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

Eric Martindale
  • 1,106
  • 1
  • 13
  • 26