Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK I found the answer: <a href="https://github.com/crcn/sift.js" rel="nofollow noreferrer">Sift.js</a></p> <p>Now for the long answer: This has been <a href="https://stackoverflow.com/questions/8695718/is-there-a-way-to-use-mongodb-query-objects-to-filter-regular-javascript-arrays">asked and answered before</a>. The salient points are:</p> <ul> <li>Use Sift if you really want Mongo syntax</li> <li>If you want to be more mainstream, use <a href="http://documentcloud.github.com/underscore/" rel="nofollow noreferrer">Underscore.js</a> like everyone else. It has heaps of handy functions in addition to the fact that it basically does what sift does with a slightly different syntax.</li> <li>You may not need any library at all - modern browsers support many useful functions directly on the <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/prototype" rel="nofollow noreferrer">Array prototype</a>, like <code>filter()</code> for example.</li> </ul> <p>As a final note, <a href="https://github.com/jostylr/mongodb-riff" rel="nofollow noreferrer">mongodb-riff</a> appears to be trying to do something similar but currently the page states clearly that it doesn't work - perhaps it's abandoned. But his readme is at least of value :-), he mentions sift and <a href="https://github.com/bevry/query-engine" rel="nofollow noreferrer">Query Engine</a> which looks more mature, though too complicated for me!</p> <p>Personally I'm going to go with Underscore because now that I've looked into it for the first time, I realise that it has heaps of handy stuff I need, plus I really only wanted to do simple functions like what would be <code>_.find()</code> in Underscore. But I guess if you want to do more complicated mongo-like queries, you'll do it in less LOC with Sift.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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