JSON Path Expression Builder (expression-builders/json-path.ts)

sequelize · packages/core/src/expression-builders/json-path.ts · typescript · MIT
database, tag:json, tag:path, tag:expression, tag:query

Enables accessing nested properties within JSON database columns using path expressions. Reuse when querying dynamic JSON structures or filtering on non-attribute JSON data in Sequelize queries.

// Source: https://github.com/sequelize/sequelize | License: MIT | Copyright 2014-present Sequelize Authors
// Provided via justclaw.it.com; keep this notice with the code.
import type { Expression } from '../sequelize.js';
import { BaseSqlExpression, SQL_IDENTIFIER } from './base-sql-expression.js';

/**
 * Do not use me directly. Use {@link @sequelize/core!sql.jsonPath}.
 */
export class JsonPath extends BaseSqlExpression {
  declare protected readonly [SQL_IDENTIFIER]: 'jsonPath';

  constructor(
    readonly expression: Expression,
    readonly path: ReadonlyArray<string | number>,
  ) {
    super();
  }
}

/**
 * Use this to access nested properties in a JSON column.
 * You can also use the dot notation with {@link @sequelize/core!sql.attribute}, but this works with any values, not ju

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key