Note that there are some explanatory texts on larger screens.

plurals
  1. POMongoDB Modeling / Querying Subset
    primarykey
    data
    text
    <p>So I'm trying to implement a model for triggering various events that could happen in my rails app.</p> <p>Some sample code of what I want it to do.</p> <pre><code> Action.trigger_on("channel1") </code></pre> <p>The above piece of code would be triggered by:</p> <pre><code> Trigger.trigger("channel1") </code></pre> <p>But then if I only want Action to be triggered for a given set of parameters I can pass a hash</p> <pre><code> Action.trigger_on("channel1", {important: true, is_transfer: true}) </code></pre> <p>The above Action will only be triggered by things on channel1 that are on "channel1" AND also it MUST be <code>important: true</code>, AND it MUST be an <code>is_transfer: true</code>.</p> <p>Hence this will NOT trigger it because it does not have is_transfer:</p> <pre><code> Trigger.trigger("channel1", {important: true}) </code></pre> <p>But this will</p> <pre><code> Trigger.trigger("channel1", {important: true, is_transfer: true}) </code></pre> <p>Right now Trigger is a document with a sub document of "properties" that contains these parameters. How do I find all the triggers that matches a subset of all the parameters? Or perhaps there is a better way to improve on this modeling?</p> <p>The stupid way to do it is to find all Triggers that matches the channel and then iterate through trough them to check to see if the current Trigger has all the desired properties.... </p> <p>EDIT: Also, I guess it is important to note that the triggering of an action is not that time critical.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload