Skip to content

Commit d076a0b

Browse files
committed
JT tech review 1
1 parent 89361a7 commit d076a0b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

docs/eloquent-models/schema-builder.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ field:
248248
To learn more about index options, see :manual:`Options for All Index Types </reference/method/db.collection.createIndex/#options-for-all-index-types>`
249249
in the {+server-docs-name+}.
250250

251+
.. _laravel-schema-builder-special-idx:
252+
251253
Create Sparse, TTL, and Unique Indexes
252254
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
253255

docs/sessions.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,23 @@ garbage collection. You can also automatically expire sessions in the
8080
database by creating a TTL index on the collection that stores session
8181
information.
8282

83-
The shell command to create a TTL index resembles the following command:
83+
You can use the ``Schema`` builder to create a TTL index, as shown in
84+
the following code:
8485

85-
.. code-block:: sh
86+
.. code-block:: php
8687

87-
db.sessions.createIndex(
88-
{ "expiry_field": 1 },
89-
{ expireAfterSeconds: 0 }
90-
)
88+
Schema::create('sessions', function (Blueprint $collection) {
89+
$collection->expire('expiry_field', 0);
90+
});
9191

92-
Setting the ``expireAfterSeconds`` value to ``0`` in the index
92+
Setting the time value to ``0`` in the index
9393
definition instructs MongoDB to expire documents at the clock time
9494
specified in the ``expiry_field`` field.
9595

96+
To learn more about using the ``Schema`` builder to create indexes, see
97+
the :ref:`laravel-schema-builder-special-idx` section of the Schema
98+
Builder guide.
99+
96100
To learn more about TTL indexes, see :manual:`Expire Data from
97101
Collections by Setting TTL </tutorial/expire-data/>` in the
98102
{+server-docs-name+}.

0 commit comments

Comments
 (0)