Skip to content

Commit 6896e26

Browse files
committed
Codeacy Appeasement: README.md
1 parent 65b1bec commit 6896e26

File tree

1 file changed

+70
-87
lines changed

1 file changed

+70
-87
lines changed

README.md

Lines changed: 70 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,46 @@
1-
Laravel MongoDB
2-
===============
1+
# Laravel MongoDB
32

43
[![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](http://img.shields.io/travis/jenssegers/laravel-mongodb.svg)](https://travis-ci.org/jenssegers/laravel-mongodb) [![Coverage Status](http://img.shields.io/coveralls/jenssegers/laravel-mongodb.svg)](https://coveralls.io/r/jenssegers/laravel-mongodb?branch=master) [![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/jenssegers)
54

6-
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.*
5+
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._
76

8-
Table of contents
9-
-----------------
10-
* [Installation](#installation)
11-
* [Upgrading](#upgrading)
12-
* [Configuration](#configuration)
13-
* [Eloquent](#eloquent)
14-
* [Optional: Alias](#optional-alias)
15-
* [Query Builder](#query-builder)
16-
* [Schema](#schema)
17-
* [Extensions](#extensions)
18-
* [Troubleshooting](#troubleshooting)
19-
* [Examples](#examples)
7+
## Table of contents
208

21-
Installation
22-
------------
9+
- [Installation](#installation)
10+
- [Upgrading](#upgrading)
11+
- [Configuration](#configuration)
12+
- [Eloquent](#eloquent)
13+
- [Optional: Alias](#optional-alias)
14+
- [Query Builder](#query-builder)
15+
- [Schema](#schema)
16+
- [Extensions](#extensions)
17+
- [Troubleshooting](#troubleshooting)
18+
- [Examples](#examples)
2319

24-
Make sure you have the MongoDB PHP driver installed. You can find installation instructions at http://php.net/manual/en/mongodb.installation.php
20+
## Installation
21+
22+
Make sure you have the MongoDB PHP driver installed. You can find installation instructions at <http://php.net/manual/en/mongodb.installation.php>
2523

2624
**WARNING**: The old mongo PHP driver is not supported anymore in versions >= 3.0.
2725

2826
Installation using composer:
2927

30-
```
31-
composer require jenssegers/mongodb
32-
```
28+
composer require jenssegers/mongodb
3329

3430
### Laravel version Compatibility
3531

36-
Laravel | Package
37-
:---------|:----------
38-
4.2.x | 2.0.x
39-
5.0.x | 2.1.x
40-
5.1.x | 2.2.x or 3.0.x
41-
5.2.x | 2.3.x or 3.0.x
42-
5.3.x | 3.1.x or 3.2.x
43-
5.4.x | 3.2.x
44-
5.5.x | 3.3.x
45-
5.6.x | 3.4.x
46-
5.7.x | 3.4.x
47-
5.8.x | 3.5.x
32+
| Laravel | Package |
33+
| :------ | :------------- |
34+
| 4.2.x | 2.0.x |
35+
| 5.0.x | 2.1.x |
36+
| 5.1.x | 2.2.x or 3.0.x |
37+
| 5.2.x | 2.3.x or 3.0.x |
38+
| 5.3.x | 3.1.x or 3.2.x |
39+
| 5.4.x | 3.2.x |
40+
| 5.5.x | 3.3.x |
41+
| 5.6.x | 3.4.x |
42+
| 5.7.x | 3.4.x |
43+
| 5.8.x | 3.5.x |
4844

4945
And add the service provider in `config/app.php`:
5046

@@ -73,8 +69,7 @@ $capsule->getDatabaseManager()->extend('mongodb', function($config, $name)
7369
});
7470
```
7571

76-
Upgrading
77-
---------
72+
## Upgrading
7873

7974
#### Upgrading from version 2 to 3
8075

@@ -108,17 +103,13 @@ Embedded relations now return an `Illuminate\Database\Eloquent\Collection` rathe
108103
$books = $user->books()->sortBy('title');
109104
```
110105

111-
Testing
112-
-------
106+
## Testing
113107

114108
To run the test for this package, run:
115109

116-
```
117-
docker-compose up
118-
```
110+
docker-compose up
119111

120-
Configuration
121-
-------------
112+
## Configuration
122113

123114
Change your default database connection name in `config/database.php`:
124115

@@ -168,10 +159,9 @@ Alternatively, you can use MongoDB connection string:
168159
],
169160
```
170161

171-
Please refer to MongoDB official docs for its URI format: https://docs.mongodb.com/manual/reference/connection-string/
162+
Please refer to MongoDB official docs for its URI format: <https://docs.mongodb.com/manual/reference/connection-string/>
172163

173-
Eloquent
174-
--------
164+
## Eloquent
175165

176166
This package includes a MongoDB enabled Eloquent class that you can use to define models for corresponding collections.
177167

@@ -205,7 +195,7 @@ class MyModel extends Eloquent {
205195
}
206196
```
207197

208-
Everything else (should) work just like the original Eloquent model. Read more about the Eloquent on http://laravel.com/docs/eloquent
198+
Everything else (should) work just like the original Eloquent model. Read more about the Eloquent on <http://laravel.com/docs/eloquent>
209199

210200
### Optional: Alias
211201

@@ -221,8 +211,7 @@ This will allow you to use the registered alias like:
221211
class MyModel extends Moloquent {}
222212
```
223213

224-
Query Builder
225-
-------------
214+
## Query Builder
226215

227216
The database driver plugs right into the original query builder. When using mongodb connections, you will be able to build fluent queries to perform database operations. For your convenience, there is a `collection` alias for `table` as well as some additional mongodb specific operators/operations.
228217

@@ -238,10 +227,9 @@ If you did not change your default database connection, you will need to specify
238227
$user = DB::connection('mongodb')->collection('users')->get();
239228
```
240229

241-
Read more about the query builder on http://laravel.com/docs/queries
230+
Read more about the query builder on <http://laravel.com/docs/queries>
242231

243-
Schema
244-
------
232+
## Schema
245233

246234
The database driver also has (limited) schema builder support. You can easily manipulate collections and set indexes:
247235

@@ -256,14 +244,14 @@ Schema::create('users', function($collection)
256244

257245
Supported operations are:
258246

259-
- create and drop
260-
- collection
261-
- hasCollection
262-
- index and dropIndex (compound indexes supported as well)
263-
- unique
264-
- background, sparse, expire, geospatial (MongoDB specific)
247+
- create and drop
248+
- collection
249+
- hasCollection
250+
- index and dropIndex (compound indexes supported as well)
251+
- unique
252+
- background, sparse, expire, geospatial (MongoDB specific)
265253

266-
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 http://laravel.com/docs/schema
254+
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 <http://laravel.com/docs/schema>
267255

268256
### Geospatial indexes
269257

@@ -287,8 +275,7 @@ Schema::create('users', function($collection)
287275
});
288276
```
289277

290-
Extensions
291-
----------
278+
## Extensions
292279

293280
### Auth
294281

@@ -331,14 +318,13 @@ Jenssegers\Mongodb\MongodbQueueServiceProvider::class,
331318

332319
### Sentry
333320

334-
If you want to use this library with [Sentry](https://cartalyst.com/manual/sentry), then check out https://github.com/jenssegers/Laravel-MongoDB-Sentry
321+
If you want to use this library with [Sentry](https://cartalyst.com/manual/sentry), then check out <https://github.com/jenssegers/Laravel-MongoDB-Sentry>
335322

336323
### Sessions
337324

338-
The MongoDB session driver is available in a separate package, check out https://github.com/jenssegers/Laravel-MongoDB-Session
325+
The MongoDB session driver is available in a separate package, check out <https://github.com/jenssegers/Laravel-MongoDB-Session>
339326

340-
Examples
341-
--------
327+
## Examples
342328

343329
### Basic Usage
344330

@@ -441,7 +427,7 @@ $users = Users::groupBy('title')->get(['title', 'name']);
441427

442428
**Aggregation**
443429

444-
*Aggregations are only available for MongoDB versions greater than 2.2.*
430+
_Aggregations are only available for MongoDB versions greater than 2.2._
445431

446432
```php
447433
$total = Order::count();
@@ -510,7 +496,7 @@ class User extends Eloquent {
510496
}
511497
```
512498

513-
For more information check http://laravel.com/docs/eloquent#soft-deleting
499+
For more information check <http://laravel.com/docs/eloquent#soft-deleting>
514500

515501
### MongoDB specific operators
516502

@@ -546,7 +532,7 @@ Selects documents where values match a specified regular expression.
546532
User::where('name', 'regex', new \MongoDB\BSON\Regex("/.*doe/i"))->get();
547533
```
548534

549-
**NOTE:** you can also use the Laravel regexp operations. These are a bit more flexible and will automatically convert your regular expression string to a MongoDB\BSON\Regex object.
535+
**NOTE:** you can also use the Laravel regexp operations. These are a bit more flexible and will automatically convert your regular expression string to a MongoDB\\BSON\\Regex object.
550536

551537
```php
552538
User::where('name', 'regexp', '/.*doe/i'))->get();
@@ -560,7 +546,7 @@ User::where('name', 'not regexp', '/.*doe/i'))->get();
560546

561547
**Type**
562548

563-
Selects documents if a field is of the specified type. For more information check: http://docs.mongodb.org/manual/reference/operator/query/type/#op._S_type
549+
Selects documents if a field is of the specified type. For more information check: <http://docs.mongodb.org/manual/reference/operator/query/type/#op._S_type>
564550

565551
```php
566552
User::where('age', 'type', 2)->get();
@@ -639,10 +625,9 @@ $locations = Location::where('location', 'geoIntersects', [
639625
]);
640626
```
641627

642-
643628
**Where**
644629

645-
Matches documents that satisfy a JavaScript expression. For more information check http://docs.mongodb.org/manual/reference/operator/query/where/#op._S_where
630+
Matches documents that satisfy a JavaScript expression. For more information check <http://docs.mongodb.org/manual/reference/operator/query/where/#op._S_where>
646631

647632
### Inserts, updates and deletes
648633

@@ -672,7 +657,7 @@ $user->email = '[email protected]';
672657
$user->save();
673658
```
674659

675-
*There is also support for upsert operations, check https://github.com/jenssegers/laravel-mongodb#mongodb-specific-operations*
660+
_There is also support for upsert operations, check <https://github.com/jenssegers/laravel-mongodb#mongodb-specific-operations>_
676661

677662
**Deleting a model**
678663

@@ -689,11 +674,11 @@ Or deleting a model by its key:
689674
User::destroy('517c43667db388101e00000f');
690675
```
691676

692-
For more information about model manipulation, check http://laravel.com/docs/eloquent#insert-update-delete
677+
For more information about model manipulation, check <http://laravel.com/docs/eloquent#insert-update-delete>
693678

694679
### Dates
695680

696-
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields, you will need to manually specify them as described here: http://laravel.com/docs/eloquent#date-mutators
681+
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields, you will need to manually specify them as described here: <http://laravel.com/docs/eloquent#date-mutators>
697682

698683
Example:
699684

@@ -717,12 +702,12 @@ $users = User::where('birthday', '>', new DateTime('-18 years'))->get();
717702

718703
Supported relations are:
719704

720-
- hasOne
721-
- hasMany
722-
- belongsTo
723-
- belongsToMany
724-
- embedsOne
725-
- embedsMany
705+
- hasOne
706+
- hasMany
707+
- belongsTo
708+
- belongsToMany
709+
- embedsOne
710+
- embedsMany
726711

727712
Example:
728713

@@ -754,7 +739,7 @@ class Item extends Eloquent {
754739
}
755740
```
756741

757-
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`:
742+
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`:
758743

759744
```php
760745
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
@@ -769,8 +754,7 @@ class User extends Eloquent {
769754
}
770755
```
771756

772-
773-
Other relations are not yet supported, but may be added in the future. Read more about these relations on http://laravel.com/docs/eloquent#relationships
757+
Other relations are not yet supported, but may be added in the future. Read more about these relations on <http://laravel.com/docs/eloquent#relationships>
774758

775759
### EmbedsMany Relations
776760

@@ -797,7 +781,7 @@ You can access the embedded models through the dynamic property:
797781
$books = User::first()->books;
798782
```
799783

800-
The inverse relation is auto*magically* available, you don't need to define this reverse relation.
784+
The inverse relation is auto_magically_ available, you don't need to define this reverse relation.
801785

802786
```php
803787
$user = $book->user;
@@ -849,7 +833,7 @@ Like other relations, embedsMany assumes the local key of the relationship based
849833
return $this->embedsMany('Book', 'local_key');
850834
```
851835

852-
Embedded relations will return a Collection of embedded items instead of a query builder. Check out the available operations here: https://laravel.com/docs/master/collections
836+
Embedded relations will return a Collection of embedded items instead of a query builder. Check out the available operations here: <https://laravel.com/docs/master/collections>
853837

854838
### EmbedsOne Relations
855839

@@ -1015,7 +999,6 @@ $projections = ['id', 'name'];
1015999
DB::collection('items')->paginate($limit, $projections);
10161000
```
10171001

1018-
10191002
**Push**
10201003

10211004
Add items to an array.
@@ -1063,7 +1046,7 @@ You may easily cache the results of a query using the remember method:
10631046
$users = User::remember(10)->get();
10641047
```
10651048

1066-
*From: http://laravel.com/docs/queries#caching-queries*
1049+
_From: <http://laravel.com/docs/queries#caching-queries>_
10671050

10681051
### Query Logging
10691052

@@ -1073,4 +1056,4 @@ By default, Laravel keeps a log in memory of all queries that have been run for
10731056
DB::connection()->disableQueryLog();
10741057
```
10751058

1076-
*From: http://laravel.com/docs/database#query-logging*
1059+
_From: <http://laravel.com/docs/database#query-logging>_

0 commit comments

Comments
 (0)