Questions tagged [laravel-mongodb]
25 questions
2
votes
1 answer
Laravel jenssegers/laravel-mongodb belongsTo relationship throwing error
I'm currently trying to create a eloquent relationship between two models in my database, one in sql and on in mongodb:

FMK
- 1,062
- 1
- 14
- 25
2
votes
2 answers
Unrecognized option to $bucket: $group
getting the above error when i run $bucket with $group in mongodb laravel.
input collection:
{
"id": "n54qllhzwdlxqvy",
"season_id": "vl7oqdehzjxr510",
"status_id": 8,
"venue_id": "",
"referee_id": "",
"neutral": 1,
…

Umayal veerappan
- 23
- 6
1
vote
1 answer
Adding withCount in mongodb request I got Illegal offset type error
In laravel 9 with MongoDB(jenssegers/mongodb 3.9) I added withCount in request :
$subscription = Subscription
::getById($subscriptionId)
->withCount('userSubscriptions')
->firstOrFail();
and got error :
[2022-08-16 14:02:18]…

mstdmstd
- 2,195
- 17
- 63
- 140
1
vote
1 answer
Update nested child elements with jenssegers/laravel-mongodb
I have a document with child elements of items like so
"bar" : "d bar",
"items" : [
{
"message" : "one",
"display" : "true",
"type" : "text"
}
{
"message" :…

zelensky
- 37
- 3
1
vote
0 answers
How to execute raw query in jenssegers/laravel-mongodb
I'm looking to make a query that gets all the existing indexes of a collection.
I have tried the following code:
DB::connection('mongodb')->getMongoDB()->execute("db.registrations.getIndexes()")
But getting error
Call to undefined method…

Soul
- 83
- 7
1
vote
1 answer
How to use groupBy Month and Sum in laravel MongoDB
Query to get monthly orders (total orders per month(count) or total sales per month(sum)):
Tried this query, but it is not working. Also tried with other results from StackOverflow, but I didn't understand how it is done with MongoDB query. This is…

RoshJ
- 461
- 1
- 6
- 24
1
vote
2 answers
update specific element from nested document array mongodb where has two matches
I need to update or create if not exist, specific obj,set score.b1 =50 and total=100 where object match curse=5 block=2
{ "_id":"sad445"
"year":2020,
"grade":4,
"seccion":"A",
"id": 100,
"name": "pedro",
"notes":[{"curse":5,
…

Carlos
- 572
- 1
- 5
- 13
1
vote
1 answer
laravel-mongoDB connection issue(Windows 10)
I need to configure mongoDB into laravel, for that I have installed MongoDB in my machine, and also enabled PHP extension for MongoDB.
Then I wrote the following command to import the MongoDB library in laravel.
composer require…

Hardik Vyas
- 500
- 1
- 7
- 27
1
vote
0 answers
get the number of children in each nodein mongodb
Recently I write an application that return relation between users.
I have a collection where documents are linked by parent_id :
{
_id:1,
parent_id:0
}
{
_id:2,
parent_id:1
}
{
_id:3,
parent_id:1
}
{
_id:4,
parent_id:2
}
{
_id:5,
…

smko
- 11
- 3
0
votes
0 answers
getting command find requires authentication from mongodb in laravel project
I have a project in laravel 8 where i have integrated mongodb. project is fetching data from 2 databases. for security perpose i have enabled the authorization in mongo.conf.
when i try to fetch data using my local machine i am getting data and…
0
votes
0 answers
jenssegers laravel-mongodb duplicating records on pagination using skip, take and limit
I have been using https://github.com/jenssegers/laravel-mongodb package for interacting with MongoDB. Whenever I fetch a document without skip(), take() and orderBy(), I do not get any duplicate entries. However when I apply skip(), take() and…

Sajid Rafique
- 1
- 1
0
votes
1 answer
How to bulk-update a date field in Laravel MongoDB?
I have a Device.php model with $dates = ['status_updated_at'].
I'd like to bulk update devices with Carbon::now().
I've tried with the following, which seems straightforward:
Device::whereIn('serial_number', $serialNumbers)->update([
…

D'Arcy Rail-Ip
- 11,505
- 11
- 42
- 67
0
votes
0 answers
How to set date value into mongodb with insert method?
Adding data into mongodb with insert method :
$published_at = $faker->dateTimeBetween($startDate = '-200 days', $endDate = 'now', config('app.timezone'));
$todayEnd = Carbon::now(config('app.timezone'));
$data[] = [
...
…

Petro Gromovo
- 1,755
- 5
- 33
- 91
0
votes
2 answers
increment or decrement without using laravel methods mangodb jassengers
I want to update documents and decrement specific column value. it is possible to use Model::where('','')->update(['count' => \DB::raw('count- 1')]); i'm using jenssegers/laravel-mongodb package.
I want decrement and update documents values…

Ali Raza
- 670
- 5
- 15
0
votes
0 answers
Getting $documents is empty on laravel-mongodb when collection is empty
I am using jenssegers/Laravel-MongoDB. Here code below:
if ($label_data_temporary_count == 0 ) {
LabelDataTemporary::insert($old_label_data_array);
} else {
$label_data_temporary->delete(); //delete previous data
…

0Zef0
- 77
- 2
- 11