jenssegers-mongodb

Laravel - Jenssegers MongoDB nested array update not working

一个人想着一个人 提交于 2019-12-23 03:22:25
问题 can someone please point out what wrong with my code? I am trying to update a nested array in MongoDB via Laravel Jenssegers. Here is my code $update_status = Journal::where('_id', "5cd10b325586e9122761f675" ) ->update( [], [ '$set' => [ "workflow.$[i].stages.$[j].stage_code" => "edit", "workflow.$[i].stages.$[j].stage_name" => "Editing" ] ], [ 'arrayFilters' => [ [ "i.basic_details.wfCode" => 'wf1' ], [ "j.stage_id" => "wf1_2" ] ] ] ); and my Journal collection is: { "_id" : ObjectId(

Laravel + Jenssegers\Mongodb: 'WhereHas' and 'Has' returns empty collection

余生颓废 提交于 2019-12-22 08:06:24
问题 I'm mainly working on two models right now, Form and Notification , and a many-to-many relationship is set up and working for most Eloquent commands, except for whereHas and has . Both just return an empty array, [] . It seems like the developer has had trouble with getting this to work in the past, but seems to have solved it here. Here's a sample of what I have so far, and what I've tried: Form.php class Form extends Eloquent { protected $connection = 'mongodb'; public function

How to convert MongoDB aggregation query to Laravel MongoDB by jenssegers

放肆的年华 提交于 2019-12-18 13:31:09
问题 I have MongoDB collection called changes which contains following data { "date" : ISODate("2014-06-09T00:00:00.000Z"), "field" : "ip", "from" : "157.11.209.123", "to" : "107.21.109.254" } { "date" : ISODate("2014-05-15T00:00:00.000Z"), "field" : "ip", "from" : "107.21.109.254", "to" : "157.11.209.123" } { "date" : ISODate("2014-06-09T00:00:00.000Z"), "field" : "registration", "from" : "Old service", "to" : "Some new service" } Then I want to make typical SQL query that counts occurrences and

Laravel MongoDB library 'jenssegers/laravel-mongodb' hasMany relationship is not working

自闭症网瘾萝莉.ら 提交于 2019-12-13 07:21:36
问题 I am using MongoDB library https://github.com/jenssegers/laravel-mongodb version 3.1.0-alpha in Laravel 5.3.28 I have two collections in MongoDB and I want to make a hasMany relation b/w them. Means each Employee performs many tasks. I have used reference and added employee_ids in the task collection. Below are my code: MongoDB: 1st Collection: Employee { "_id" : ObjectId("586ca8c71a72cb07a681566d"), "employee_name" : "John", "employee_description" : "test description", "employee_email" :

MongoDB\Driver\Exception\InvalidArgumentException Integer overflow detected on your platform: 300000000000

无人久伴 提交于 2019-12-11 05:39:16
问题 I'm getting error when i try indexing my document using laravel. This is my main code. By using die statements, I came to know that i'm getting this error "[MongoDB\Driver\Exception\InvalidArgumentException] Integer overflow detected on your platform: 300000000000" as soon as it executes first line : $users = User::all(); $users = User::all(); foreach ($users as $user) { $temp=$user['attributes']; unset($temp['_id']); $params = [ 'index' => 'test_index', 'type' => $temp['vehicle_type'], 'id'

MongoDB query for aggregate function retuning empty result

无人久伴 提交于 2019-12-11 02:34:58
问题 Following is the query i had written to get the count based on event name. $data= DB::collection(Events::$collection)->raw(function($collection) { return $collection->aggregate([ ['$match' => ['appid' => 1]], ['$group' => ['_id' =>['Event' =>'$Event'], 'count' =>['$sum'=>1]]] ]); }); When i print the above query using laravel eloquent query logs its displays the output as follows : Array ( [query] => events.aggregate([{"$match":{"appid":1}},{"$group":{"_id":{"Event":"$Event"},"count":{"$sum"

belongsToMany, hybrid relation

别说谁变了你拦得住时间么 提交于 2019-12-06 13:35:51
问题 I have 2 simple models. First, one is called Builds (mysql) and the second one is called SlotOptions (mongodb). Each build can have 5 assigned slots. Based on https://stackoverflow.com/a/55132863/2513428 select * from `builds` where `builds`.`id` = 37 limit 1 SlotOptions.find({"heroName":{"$in":[37]}},{"typeMap":{"root":"array","document":"array"}}) Table. build_slot_option (mysql) +----------------+--------+----------------------------------------+ | Name | Type | Desc | +----------------+--

Eloquent Outside of Laravel with jenssegers/laravel-mongodb multiple DB connections

偶尔善良 提交于 2019-12-06 09:30:42
问题 I am trying to connect Eloquent to multiple databases sqlserver for the default and mongodb for the secondary connection. I am using jenssegers/laravel-mongodb pulled in using composer. Here is my database file use Illuminate\Database\Capsule\Manager as Capsule; $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'sqlsrv', 'host' => '******', 'database' => '*****', 'username' => '*****', 'password' => '*****', 'prefix' => '', ], 'default'); $capsule->addConnection([ 'driver' =>