I am developing a generic subscription system where the user can specify a compound rule during subscription in terms of a MongoDB request or, moreover, a json request. Subscription data is stored in the MongoDB collection. For instance,
{ "userId": 1, "rule": {"p1": "a"} } { "userId": 2, "rule": {"p1": "a", "p2": "b"} } { "userId": 3, "rule": {"p3": {$gt: 3} } }
Later, when an event occurs in the form of a json object, for example the following, I want to find all the user rules that should be executed in this case:
{"p1": "a", "p3": 4}
The above event must comply with the rules specified in examples 1 and 3 of the user. The event object should not be stored in MongoDB.
Although I can probably fulfill this requirement by writing a loop at the application level. For efficiency, I really want to implement it at the db level, it is advisable to allow distributed (plastered) execution due to volume and latency requirements.
Is it possible? Any help is appreciated. In fact, I am open to other NOSQL dbs, while a dynamic event schema is supported, and there is a way to specify a compound rule.
source share