Unverified Commit 7e91b7a0 authored by rennokki's avatar rennokki Committed by GitHub

wip

parent 29807a2a
...@@ -3,7 +3,7 @@ Laravel MongoDB ...@@ -3,7 +3,7 @@ Laravel MongoDB
[![Latest Stable Version](http://img.shields.io/github/release/jenssegers/laravel-mongodb.svg)](https://packagist.org/packages/jenssegers/mongodb) [![Total Downloads](http://img.shields.io/packagist/dm/jenssegers/mongodb.svg)](https://packagist.org/packages/jenssegers/mongodb) [![Build Status](https://img.shields.io/github/workflow/status/jenssegers/laravel-mongodb/CI)](https://github.com/jenssegers/laravel-mongodb/actions) [![Coverage Status](https://coveralls.io/repos/github/jenssegers/laravel-mongodb/badge.svg?branch=master)](https://coveralls.io/github/jenssegers/laravel-mongodb?branch=master) [![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/jenssegers) [![Latest Stable Version](http://img.shields.io/github/release/jenssegers/laravel-mongodb.svg)](https://packagist.org/packages/jenssegers/mongodb) [![Total Downloads](http://img.shields.io/packagist/dm/jenssegers/mongodb.svg)](https://packagist.org/packages/jenssegers/mongodb) [![Build Status](https://img.shields.io/github/workflow/status/jenssegers/laravel-mongodb/CI)](https://github.com/jenssegers/laravel-mongodb/actions) [![Coverage Status](https://coveralls.io/repos/github/jenssegers/laravel-mongodb/badge.svg?branch=master)](https://coveralls.io/github/jenssegers/laravel-mongodb?branch=master) [![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/jenssegers)
Laravel Eloquent add support for ODM (Object Document Mapper) to Laravel. It's the same as Eloquent ORM, but with Documents, since MongoDB is a NoSQL database. Laravel Eloquent adds support for ODM (Object Document Mapper) to Laravel. It's the same as Eloquent ORM, but with Documents, since MongoDB is a NoSQL database.
Table of contents Table of contents
----------------- -----------------
...@@ -112,7 +112,7 @@ Upgrading ...@@ -112,7 +112,7 @@ Upgrading
In this new major release which supports the new MongoDB PHP extension, we also moved the location of the Model class and replaced the MySQL model class with a trait. In this new major release which supports the new MongoDB PHP extension, we also moved the location of the Model class and replaced the MySQL model class with a trait.
Please change all `Jenssegers\Mongodb\Model` references to `Jenssegers\Mongodb\Eloquent\Model` either at the top of your model files, or your registered alias. Please change all `Jenssegers\Mongodb\Model` references to `Jenssegers\Mongodb\Eloquent\Model` either at the top of your model files or your registered alias.
```php ```php
use Jenssegers\Mongodb\Eloquent\Model; use Jenssegers\Mongodb\Eloquent\Model;
...@@ -156,7 +156,7 @@ docker-compose up ...@@ -156,7 +156,7 @@ docker-compose up
Configuration Configuration
------------- -------------
You can use MongoDB either as a main database, either as a side database. To do so, add a new `mongodb` connection to `config/database.php`: You can use MongoDB either as the main database, either as a side database. To do so, add a new `mongodb` connection to `config/database.php`:
```php ```php
'mongodb' => [ 'mongodb' => [
...@@ -175,7 +175,7 @@ You can use MongoDB either as a main database, either as a side database. To do ...@@ -175,7 +175,7 @@ You can use MongoDB either as a main database, either as a side database. To do
], ],
``` ```
For multiple servers or replica set configurations, set the host to array and specify each server host: For multiple servers or replica set configurations, set the host to an array and specify each server host:
```php ```php
'mongodb' => [ 'mongodb' => [
...@@ -188,7 +188,7 @@ For multiple servers or replica set configurations, set the host to array and sp ...@@ -188,7 +188,7 @@ For multiple servers or replica set configurations, set the host to array and sp
], ],
``` ```
If you wish to use a connection string instead of a full key-value params, you can set it so. Check the documentation on MongoDB's URI format: https://docs.mongodb.com/manual/reference/connection-string/ If you wish to use a connection string instead of full key-value params, you can set it so. Check the documentation on MongoDB's URI format: https://docs.mongodb.com/manual/reference/connection-string/
```php ```php
'mongodb' => [ 'mongodb' => [
...@@ -226,7 +226,7 @@ class Book extends Model ...@@ -226,7 +226,7 @@ class Book extends Model
} }
``` ```
**NOTE:** MongoDb documents are automatically stored with an unique ID that is stored in the `_id` property. If you wish to use your own ID, substitude the `$primaryKey` property and set it to your own primary key attribute name. **NOTE:** MongoDB documents are automatically stored with a unique ID that is stored in the `_id` property. If you wish to use your own ID, substitute the `$primaryKey` property and set it to your own primary key attribute name.
```php ```php
use Jenssegers\Mongodb\Eloquent\Model; use Jenssegers\Mongodb\Eloquent\Model;
...@@ -339,7 +339,7 @@ $users = ...@@ -339,7 +339,7 @@ $users =
$users = User::whereIn('age', [16, 18, 20])->get(); $users = User::whereIn('age', [16, 18, 20])->get();
``` ```
When using `whereNotIn` objects will be returned if the field is non existent. Combine with `whereNotNull('age')` to leave out those documents. When using `whereNotIn` objects will be returned if the field is non-existent. Combine with `whereNotNull('age')` to leave out those documents.
**whereBetween** **whereBetween**
...@@ -767,7 +767,7 @@ class Item extends Model ...@@ -767,7 +767,7 @@ class Item extends Model
### belongsToMany and pivots ### belongsToMany and pivots
The belongsToMany relation will not use a pivot "table", but will push id's to a __related_ids__ attribute instead. This makes the second parameter for the belongsToMany method useless. The belongsToMany relation will not use a pivot "table" but will push id's to a __related_ids__ attribute instead. This makes the second parameter for the belongsToMany method useless.
If you want to define custom keys for your relation, set it to `null`: If you want to define custom keys for your relation, set it to `null`:
...@@ -787,7 +787,7 @@ class User extends Model ...@@ -787,7 +787,7 @@ class User extends Model
### EmbedsMany Relationship ### EmbedsMany Relationship
If you want to embed models, rather than referencing them, you can use the `embedsMany` relation. This relation is similar to the `hasMany` relation, but embeds the models inside the parent object. If you want to embed models, rather than referencing them, you can use the `embedsMany` relation. This relation is similar to the `hasMany` relation but embeds the models inside the parent object.
**REMEMBER**: These relations return Eloquent collections, they don't return query builder objects! **REMEMBER**: These relations return Eloquent collections, they don't return query builder objects!
...@@ -1000,7 +1000,7 @@ MongoDB specific operations: ...@@ -1000,7 +1000,7 @@ MongoDB specific operations:
- expire - expire
- geospatial - geospatial
All other (unsupported) operations are implemented as dummy pass-through methods, because MongoDB does not use a predefined schema. All other (unsupported) operations are implemented as dummy pass-through methods because MongoDB does not use a predefined schema.
Read more about the schema builder on [Laravel Docs](https://laravel.com/docs/6.0/migrations#tables) Read more about the schema builder on [Laravel Docs](https://laravel.com/docs/6.0/migrations#tables)
...@@ -1033,11 +1033,11 @@ If you're using a hybrid MongoDB and SQL setup, you can define relationships acr ...@@ -1033,11 +1033,11 @@ If you're using a hybrid MongoDB and SQL setup, you can define relationships acr
The model will automatically return a MongoDB-related or SQL-related relation based on the type of the related model. The model will automatically return a MongoDB-related or SQL-related relation based on the type of the related model.
If you want this functionality to work both ways, your SQL-models will need use the `Jenssegers\Mongodb\Eloquent\HybridRelations` trait. If you want this functionality to work both ways, your SQL-models will need to use the `Jenssegers\Mongodb\Eloquent\HybridRelations` trait.
**This functionality only works for `hasOne`, `hasMany` and `belongsTo`.** **This functionality only works for `hasOne`, `hasMany` and `belongsTo`.**
The MySQL model shoul use the `HybridRelations` trait: The MySQL model should use the `HybridRelations` trait:
```php ```php
use Jenssegers\Mongodb\Eloquent\HybridRelations; use Jenssegers\Mongodb\Eloquent\HybridRelations;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment