Questions tagged [jenssegers-mongodb]

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

An Eloquent model and Query builder with support for MongoDB, using the original Laravel API. This library extends the original Laravel classes, so it uses exactly the same methods.

GitHub Link

192 questions
0
votes
2 answers

How to get sub-document size (count) in laravel mongodb jenssegers

I want to fetch comment counts instead of fetching all comments in a single query, The below code I am using but getting the error $answers = Answers::project([ 'comments'=>0, 'comments_count' => [ '$size' => '$comments' ]]) …
0
votes
2 answers

How to access data returned in MongoDB cursor in laravel controller?

I am using Laravel 5.6 with MongoDB using Jenssegers Package Here I want to get total count using group by a method as we do in Mysql eg. select latitude,longitude,count(*) as `count` from event_logger group by latitude,longitude According to docs…
Dinesh Suthar
  • 853
  • 1
  • 17
  • 41
0
votes
1 answer

How To Use Get On Eager-loaded Attribute In Laravel Eloquent Jensseger Mongodb

I am using Laravel with jenssegers Mongodb Eloquent. When I try to use get([...]) or distinct('...') it gives null values in the result. How can I use get([eager_loaded_attribute_here]) to get only a given attribute that was…
Daniel Valland
  • 1,057
  • 4
  • 21
  • 45
0
votes
1 answer

Jensseger Mongodb Laravel - Order By Attribute On Embeded Document

How can i order by attributes on a subdocument (lazy-loaded from belongsTo relation)? I have: Message::with(['conversation']) ->where(.....) ->get() This returns: [ { "_id": "5aee075893782d1b1f460b13", ...... "updated_at":…
Daniel Valland
  • 1,057
  • 4
  • 21
  • 45
0
votes
1 answer

Update and unset not working MongoDB and Laravel

I am new to MongoDB and i am using jenssegers/laravel-mongodb package for build an API. I am facing problem while updating and deleting a records in array. Here is My code of update using foreach foreach ($event->volunteers as $key => $volunteer)…
Prafful Panwar
  • 439
  • 7
  • 19
0
votes
1 answer

Converting MongoDB query to jenssegers/laravel-mongodb

How would you write a query like this db.collection.find({$expr: {$lte: [{ $mod: [ '$created_at', 3600 ] }, 59]}}); using the jenssegers/laravel-mongodb extension
user3010617
  • 137
  • 1
  • 12
0
votes
2 answers

Updating object in nested array MongoDB and laravel

I am trying to update single object inside an array that exist inside another array (nested array) but what happen that all records are removed and the new records are inserted instead this is the structure I am using: "summary_mark" : [ { …
0
votes
1 answer

How to use unwind in jenssegers/laravel-mongodb?

I am using mongodb with Laravel. I also using jenssegers/laravel-mongodb for performing database activity. I have one collection containing data of the user where the path of his picture is stored with the tags given by him. Somewhat similar to…
0
votes
1 answer

Search a common field in objects embedded in an object in mongodb

I have a document like bellow: books: [ {_id: 1,chapters:{0:{title:'ch1'},1:{title:'ch2'},2:{title:'ch3'}},description:'book one'}, {_id: 2,chapters:{0:{title:'ch4'},1:{title:'ch2'},2:{title:'ch5'}},description:'book two'}, {_id:…
0
votes
2 answers

How to find record matching the nested key laravel mongodb jenssegers

I am using jenssegers mongodb package in laravel for querying mongodb. How to retrieve the records matching only the games as cricket in the below json document. { "_id": ObjectId("53402597d852426020000002"), "contact":…
oldrock
  • 841
  • 2
  • 13
  • 26
0
votes
2 answers

Laravel Relationship with Array value

I am using one to one relationship. My model code is: public function training_type() { return $this->hasone('App\Training_type','id','type'); } but the parameter "id" is within an array, i tried with following code but not working: public…
0
votes
2 answers

Find documents with matching the field's object value

My mongodb table has a field which has object value like _id : ObjectId("59ad227e191cc3a4c33ade07") user_info : {"first_name": "Shraddha", "last_name": "Banerjee", "Zip": "90242", "City": "SantaBarbara"} I want to find the users with Zip: 90242. I…
0
votes
1 answer

Laravel Spark 4.0: Unsupported driver [mongodb]

I tried installing package jenssegers/laravel-mongodb to add mongodb support to my existing Laravel Spark app that runs with MySQL database. My code with error: DB::connection('mongodb') ->collection('sample_data') …
arjayads
  • 553
  • 1
  • 5
  • 17
0
votes
0 answers

MongoDB models relationships in Laravel

this is Post model data: { "_id" : ObjectId("58bb1293534e2028d0006f33"), "body" : "Some body", "comments" : [ { "commentID" : "58bb115c534e2028d0006f2d" }, { "commentID" : "58bb1153534e2028d0006f2c" …
Homayoon
  • 31
  • 5
0
votes
1 answer

Laravel 5.4 with MongoDB - trying to retrieve embedded documents

I have a MongoDB collection set up with multiple embedded documents. This is how my sample document looks like: { "_id" : ObjectId("58a331ffb854d000f97862f3"), "first_name" : "John", "last_name" : "Doe", "email" : "test@test.com", …
ignite-me
  • 738
  • 3
  • 14
  • 33