Function escapeFieldNames

  • Overview (template-string overload)

    Escapes field names which may contain .s and &s for use in Data API queries.

    This overload allows you to use a tagged template string to create an escaped field path.

    🚨Important: This should NOT be used for insertion operations. It is only for use in areas where a field path is required; not just a field name (e.g. filters, projections, updates, etc.)

    Parameters

    • segments: TemplateStringsArray
    • Rest ...args: PathSegment[]

    Returns string

    Example

    import { escapeFieldNames } from '@datastax/astra-db-ts';

    // 'websites.www&.datastax&.com.visits'
    const domain = 'www.datastax.com';
    escapeFieldNames`websites.${domain}.visits`

    // 'shows.tom&&jerry.episodes.3.views
    const episode = 3;
    escapeFieldNames`shows.${'tom&jerry'}.episodes.${episode}.views`

    See

    unescapeFieldPath

  • Overview (varargs overload)

    Escapes field names which may contain .s and &s for use in Data API queries.

    This overload allows you to pass a variable number of arguments to create an escaped field path.

    🚨Important: This should NOT be used for insertion operations. It is only for use in areas where a field path is required; not just a field name (e.g. filters, projections, updates, etc.)

    Parameters

    Returns string

    Example

    import { escapeFieldNames } from '@datastax/astra-db-ts';

    // 'websites.www&.datastax&.com.visits'
    const domain = 'www.datastax.com';
    escapeFieldNames('websites', domain, 'visits')

    // 'shows.tom&&jerry.episodes.3.views
    const episode = 3;
    escapeFieldNames('shows', 'tom&jerry', 'episodes', episode, 'views')

    See

    unescapeFieldPath

  • Overview (iterable overload)

    Escapes field names which may contain .s and &s for use in Data API queries.

    This over load allows you to pass an iterable (like an array) of segments to create an escaped field path.

    🚨Important: This should NOT be used for insertion operations. It is only for use in areas where a field path is required; not just a field name (e.g. filters, projections, updates, etc.)

    Parameters

    Returns string

    Example

    import { escapeFieldNames } from '@datastax/astra-db-ts';

    // 'websites.www&.datastax&.com.visits'
    const domain = 'www.datastax.com';
    escapeFieldNames(['websites', domain, 'visits'])

    // 'shows.tom&&jerry.episodes.3.views
    const episode = 3;
    escapeFieldNames(['shows', 'tom&jerry', 'episodes', episode, 'views'])

    See

    unescapeFieldPath