Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe the initial issue starts with your data structure for each feed document. Notice that your object is simply an id, and then an incrementing amount of number keys, and thats it. What would be ideal is that you insert an actual object structure, with keys and values, at the top level. Currently, because you directly dumped the facebook data straight into mongo without formatting it, the driver mapped your array to key/value. Now each feed doc has variable amount of anonymous objects.</p> <p>Refer to this: <a href="http://www.php.net/manual/en/mongo.writes.php" rel="nofollow">http://www.php.net/manual/en/mongo.writes.php</a></p> <p>What I would think your feed doc should look like might be this:</p> <pre><code>{ "_id" : ObjectId("4f7db4dd6434e64959000000"), "posts" : [ { "story" : "Text of a story I posted on my wall...", "message" : "In this case message text exists as well...", }, { "story" : "Text of a story I posted on my wall...", "message" : "In this case message text exists as well...", } ], "posts_meta1": "some val", "posts_meta2": "other data" } </code></pre> <p>Notice that it contains a "posts" top level key, with your array of post objects underneath. This fixes multiple issues. You have a top level key to index with, instead of "number", you have a cleaner root level for adding more feed fields, and you can cleanly achieve your find query.</p> <p>A simple find might look like this: </p> <pre><code>// Return all feed docs, and only include the posts.story field db.feeds.find({}, {"posts.story": 1}) </code></pre> <p>A more advanced query might look like this:</p> <pre><code>// Return an feed document that either contains a posts.story // field, or, contains a posts.message field db.feeds.find({ $or: [ {$exists: {"posts.story": true}}, {$exists: {"posts.message": true} ] }) </code></pre> <p>In a nutshell, your data returned from facebook should be formatted first into an object structure, and then inserted into mongo. For instance, dates should be inserted as proper date objects as opposed to raw strings: <a href="http://www.php.net/manual/en/class.mongodate.php" rel="nofollow">http://www.php.net/manual/en/class.mongodate.php</a>. This allows you to then do date-based queries in mongo, and the php driver will also make sure to convert them back and forth so that they are more native to your language.</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. 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