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
1 answer

How to store activity log in mongo db from laravel?

I am using spatie/laravel-activitylog to log the activities and jenssegers/laravel-mongodb connect to a Mongo database. In user Model, the user data is storing into mysql and log data need to be stored in mongodb. I am getting "Call to a member…
0
votes
1 answer

How to add a new item to the sub array of a specific document only if the size of the sub array is less than 50 in mongo collection

I have a users collection in my mongoDB. Now I want to update favorites array only if its size is less than 50. "_id": 'mongo_id', "name": "test user", "email": "test_4@gmail.com", "full_name": "", "first_name": "", "last_name": "", …
kakurala
  • 824
  • 6
  • 15
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…
0
votes
0 answers

How to filter NaN values in Laravel Query

I have a MongoDB collection with a test field which is a float. For some records, test is equal to NaN. When I try and make a query in Laravel I cannot retrieve the latest record where test is not NaN. $myData = MyData::where('reference', '=',…
Thbwun
  • 323
  • 1
  • 3
  • 14
0
votes
1 answer

How with jenssegers/mongodb get last Insert Id?

On Laravel site using jenssegers/mongodb I have store method like : public function store(ItemRequest $request) { $request = request(); try { $session = DB::getMongoClient()->startSession(); $session->startTransaction(); …
Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
0
votes
1 answer

reference id with mongodb by laravel jenssegers

i have two models, i need to get model A data that have reference in model B by array id, this is my model A object { "_id": "62eb2f788345c04a74057903", "location": "usa" } and this is my model B { "_id":…
0
votes
0 answers

Set option bypassDocumentValidation for Laravel MongoDB (jenssegers/mongodb)

I try to update my Eloquent model while bypassing the validation (because some items break their schema). As I understand the mongodb package, it should be possible to pass an option ['bypassDocumentValidation' => true] I tried to set this option…
0
votes
2 answers

mongodb update/upsert that adds data to the existing document instead of replacing data in an existing document

I am using an upsert using mongodb's Jensseger PHP library. Every time I add new data to the document it updates the value of the field if the field names are the same. I want to add to the document's data instead of replacing it. An example of a…
SJW525
  • 51
  • 1
  • 9
0
votes
1 answer

Call to a member function beginTransaction() on null using laravel excel and mongodb as database

I get the message Call to a member function beginTransaction() on null when importing data from "Maatwebsite\Excel\Excel" using laravel 8.0 and MongoDB. Export is ok, I've already tried to set transaction handler to 'null' and php artisan…
Daitarn
  • 109
  • 1
  • 15
0
votes
1 answer

Get multiple average values in raw expression - Laravel MongoDB jenssegers

I am using Laravel with MongoDB and jenssegers package. I have a collection called ProductDetails in which I have three fields for which I need to retrieve the average value: price, margin and weight. I can make three different queries but I would…
Thbwun
  • 323
  • 1
  • 3
  • 14
0
votes
0 answers

Query Builder receiving MySqlConnection for `jenssegers/laravel-mongodb` using Laravel 8

I am having trouble setting up a MongoDB-based Laravel 8 app using jenssegers/laravel-mongodb. After setting up the necessary resource controllers, routes and models, calling any of the API routes results in the following…
0
votes
0 answers

Call to a member function beginTransaction() on null

I am getting Call to a member function beginTransaction() on null when importing data from "Maatwebsite\Excel\Excel" using lumen and MongoDB.
0
votes
1 answer

laravel-mongodb ORDER BY FIELD not working

I've been reading some documentations here and really not been able to find a solution on how to order the results in a specific order of a field name. NOT ALPHABETICALLY in a descending nor ascending order. Wanted to have this result: $models =…
user3233787
  • 379
  • 1
  • 10
  • 32
0
votes
0 answers

getting error Call to a member function prepare() on null in mongodb db in laravel

I am using mongodb in laravel v8, to use mongodb database i used this composer require jenssegers/mongodb library, i am using this library and trying to insert 1 record, with this query…
Nikul Panchal
  • 1,542
  • 3
  • 35
  • 58
0
votes
1 answer

How to replace collection in query result Mongo

I queried to get info from a table with a manytomany relationship like this $userList = UserListing::where('user_id', $user->id)->with("objects")->paginate(10); Now, i want to limit the amount of results in the "Objects" table, but at the same time…
Efraín
  • 453
  • 1
  • 7
  • 13