Skip to main content
https://api.travis-ci.org/drorasaf/mongotriggers.svg?branch=master https://coveralls.io/repos/github/drorasaf/mongotriggers/badge.svg?branch=master https://img.shields.io/pypi/v/mongotriggers.svg https://img.shields.io/pypi/dm/mongotriggers.svg Documentation Status

What is this?

mongodb-triggers is a light-weight library to allow real live changes notification. This is similar to triggers in SQL. This capability can be found both in Java and JavaScript(MeteorJS)

What is it good for?

Modern applications have become near real-time response and updates, this leads to the requirement that any changes done in the data to be propagated up to the top level of the application as soon as possible.

In order to allow this to happen, any changes in the databases must be notified, similar project that use this method is https://github.com/meteor/meteor.

More Documentation can be found at http://mongotriggers.readthedocs.io

Installation

Installer is available on PyPI. You can install it through pip:

$ pip install mongotriggers

Why should I use it?

The best functionality is the one that another one is maintaining for you, as well as 100% code coverage. This package follows best practices as published by MongoDB: - https://www.mongodb.com/blog/post/tailing-mongodb-oplog-sharded-clusters - https://www.mongodb.com/blog/post/pitfalls-and-workarounds-for-tailing-the-oplog-on-a-mongodb-sharded-cluster

How to use?

Let’s assume the system in development is a financial one, and every deletion in the database is extremely important, so we would like to notified for each deletion.

from mongotriggers import MongoTrigger
from pymongo import MongoClient

def notify_manager(op_document):
    print ('wake up! someone is adding me money')

client = MongoClient(host='localhost', port=27017)
triggers = MongoTrigger(conn)
triggers.register_op_trigger(notify_manager, 'my_account', 'my_transactions')

triggers.tail_oplog()
client['my_account']['my_transactions'].insert_one({"balance": 1000})
triggers.stop_tail()

Keep in mind that it is meant to run in a defered context in order to run endlessly until it is cancelled.

Testing

In order to develop, the additional requirements are:

  • pytest

  • pytest-cov

  • tox

All packages can be installed using pip. The easiest way to run the tests is to run tox.

Metadata

Release files for mongotriggers 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongotriggers 2.0.1
File Size Uploaded
mongotriggers-2.0.1.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mongotriggers 2.0.1
File Interpreter ABI Platform
mongotriggers-2.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 20.5 kB

Release files / mongotriggers-2.0.1.tar.gz

Download URL mongotriggers-2.0.1.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
74a31438a9013c72906a3b7f07a13bf2f688832090d03103036f11c7425112a4
BLAKE2b-256 checksum
How to use checksums
1e8ffd70e3290242d2c3c02a8878127e2bd91161f380d81c07735c656a1ec1c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / mongotriggers-2.0.1-py2.py3-none-any.whl

Download URL mongotriggers-2.0.1-py2.py3-none-any.whl
Size 7.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
220c69eef774510898ce52ba5bafc39e741d641f34349edc094fde6d8b196ffd
BLAKE2b-256 checksum
How to use checksums
4984fa233d8888593cca7a8094a7981896ca39579ada056b92330a78e4ed52d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page