We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Selecting row from MongoDB

I am new to Phalcon ODM. I want to display all posts from post collection, which have post_type = blog. Here is the document

{
    "_id" : ObjectId("53f88231461584e41e00002a"),
    "post" : {
        "post_date" : "12-05-14",
        "post_title" : "Title",
        "post_content" : "Content",
        "post_category" : "test cat",
        "post_type" : "blog",
        "post_status" : "published",
        "post_modified" : "12-05-14"
    },
    "comment_status" : "open",
    "link_code" : "test-blog",
    "seo" : {
        "meta_desc" : "test desc",
        "meta_key" : "test key"
    }
}


24.2k
Accepted
answer

Finally I got the answer

$post = Posts::find(array(
                'conditions'=>array('post_con.post_type'=>'blog') ));
                $this->view->postlist = $post; 

The above code will select all blog posts.

In volt,

{% for posts in postlist %}
{{ posts.post_con['post_title'] }}
{{ posts.post_con['post_date'] }}

will do the job