jenssegers-mongodb

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

三世轮回 提交于 2019-12-05 14:44:40
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 notifications(){ return $this->belongsToMany('App\Api\Forms\Notification', null, 'form_ids', 'notification_ids');

belongsToMany, hybrid relation

懵懂的女人 提交于 2019-12-04 18:20:25
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 | +----------------+--------+----------------------------------------+ | slot_option_id | char50 | // FK, Name of slot option

Laravel Jensseger Mongodb belongsToMany returns empty array

拟墨画扇 提交于 2019-12-02 18:37:36
问题 I am trying to use a belongsToMany relation, in the following way: Model with belongsToMany relation: namespace App\Models; use Illuminate\Notifications\Notifiable; use Laravel\Passport\HasApiTokens; class Notification extends \Jenssegers\Mongodb\Eloquent\Model { use Notifiable, HasApiTokens; protected $collection = 'myDb.notifications'; protected $fillable = [ ]; protected $hidden = [ ]; /** * List of involved users */ public function participants() { return $this->belongsToMany(User::class)

select sum column and group by with Mongodb and Laravel

落花浮王杯 提交于 2019-12-02 09:16:01
问题 I have a issue with my query: I want to SELECT "user_info" with SUM "amount" and GROUP BY "user_id" I am using Laravel 5 and jenssegers/laravel-mongodb Thank you so much. 回答1: http://laravel.io/forum/10-05-2014-raw-select-using-jenssegers-laravel-mongodb check link above or use this as i write. $total = DB::table('user_info')->sum('amount')->groupBy('user_id')->get(); 回答2: For better performance use the underlying MongoDB driver's aggregation framework methods as this uses the native code on

select sum column and group by with Mongodb and Laravel

混江龙づ霸主 提交于 2019-12-02 07:33:26
I have a issue with my query: I want to SELECT "user_info" with SUM "amount" and GROUP BY "user_id" I am using Laravel 5 and jenssegers/laravel-mongodb Thank you so much. http://laravel.io/forum/10-05-2014-raw-select-using-jenssegers-laravel-mongodb check link above or use this as i write. $total = DB::table('user_info')->sum('amount')->groupBy('user_id')->get(); For better performance use the underlying MongoDB driver's aggregation framework methods as this uses the native code on the MongoDB server rather than the .groupBy() methods which basically wraps mapReduce methods. Consider the

hasMany relationship issue in Laravel 5.3 + MongoDB library 'jenssegers/laravel-mongodb'

≡放荡痞女 提交于 2019-12-02 03:45:55
问题 I am using MongoDB library in Laravel 5.3 . I have two collections in MongoDB and I want to make a hasMany relation b/w them. MongoDB: 1st Collection: Employee { "_id" : ObjectId("586ca8c71a72cb07a681566d"), "employee_name" : "John", "employee_description" : "test description", "employee_email" : "john@email.com", "updated_at" : "2017-01-04 11:45:20", "created_at" : "2017-01-04 11:45:20" }, { "_id" : ObjectId("586ca8d31a72cb07a6815671"), "employee_name" : "Carlos", "employee_description" :

How to convert MongoDB aggregation query to Laravel MongoDB by jenssegers

那年仲夏 提交于 2019-11-30 10:01:11
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 group it by field . So, I've created query in MongoDB db.changes.group({ "key": { "field": true },

Connect laravel jenssegers to mongodb atlas cluster

偶尔善良 提交于 2019-11-27 16:59:26
问题 I'am starting with Mongodb atlas and i trying to connect my laravel/jenssegers project to the cluster i config my conf/database 'mongodb' => [ 'driver' => 'mongodb', 'host' => env('DB_HOST'), 'port' => env('DB_PORT', '27017'), 'database' => env('DB_DATABASE'), 'username' => env('DB_USERNAME'), 'password' => env('DB_PASSWORD'), 'options' => [ 'database' => 'admin' // sets the authentication database required by mongo 3 ] ], And my .env file DB_HOST="xxxx-shard-00-00-uggj0.mongodb.net" DB_PORT