Responsive Ad Area

Share This Post

test

jenssegers/laravel-mongodb’s where() and raw() produces different result for same query

I am using jessengers/laravel-mongodb in one of my project. I would like to use raw mongodb query rather than the other functions in jessengers library. when i write a simple query using raw() to get two field values from database, it returns the complete document. So i tried with where() function, the cursor shows the requested fields only.

I am afraid why the same query shows two different results…

Here is the query with where() function:

$articleDataArray = Article::where('art_xml_data.article.article_id', '=', $articleId)
                ->get(['art_status', 'art_file_path']);

This query returns a cursor having art_status and art_file_path values only.

But the below query when written in raw() returns the complete fields in the matched document.

$articleDataArray = Article::raw()->find(
                    array ('art_xml_data.article.article_id' => $article->article_name), 
                    array ('art_status' => 1, 'art_file_path' => 1)
                )->toArray();


jenssegers/laravel-mongodb’s where() and raw() produces different result for same query
jenssegers/laravel-mongodb’s where() and raw() produces different result for same query
test
{$excerpt:n}

Share This Post

Leave a Reply

Your email address will not be Publishedd. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Skip to toolbar