Querying JSON and JSONB data
As stated previously, JSON column types are only available for SQLite, MySQL, MariaDB, and PostgreSQL. The JSONB column is only supported on the PostgreSQL DBMS. The difference between the two column types is that JSONB will store additional information related to the fields within the JSON document internally. This will increase the requirements for disk space but will help make querying the data quicker.
For this section, presume that we have the following model within our application:
class Receipts extends Model {} Receipts.init({ receipt: DataTypes.JSON });
Now, we can create our document:
await Receipts.create({ receipt: { name: { first: "Bob", last: "Smith" ...