Purpose and implementation of json field type in laravel schema builder

What is the purpose $table->json('options');as the type of the database field of the laravel database database. I was looking for a hard search, but could not get any relevant information about it. Please indicate one purpose of the state list with an example.

+4
source share
2 answers

Some database engines - PostgreSQL, which is the main example - have JSON-friendly data types (which MySQL currently lacks - it will simply store as the data type TEXTthere). This can be convenient for working with data (for example, the example optionsthat you are quoting), which can contain a large amount of uncharted or loosely structured data.

Instead of having 100+ columns for a bunch of on / off parameters for the model, you can save them in a JSON object in the database.

+5
source

This is sometimes useful, even if MySQL stores data as JSON.

, , . , ? , JSON .

+2

All Articles