@statlertronik/ids-to-path-string
Helper utility generate key strings for REST API from array of key values.
How to use it
to install:
npm install @statlertronik/ids-to-path-string
in code (typescript):
/*--------------------------------------------------------------------*/
/* Creating 'Collection+JSON' response object with collection data */
/* and with references to 'queries' & 'template' objects. */
/*--------------------------------------------------------------------*/
import {
KeyValueType,
ids2PathString
} from '@statlertronik/ids-to-path-string';
cost ids: KeyValueType[] = ["John", 123];
const key: string = ids2PathString(ids); // returns: "John_123"
...
API
type KeyValueType = string | number | boolean;
ids2PathString(ids: KeyValueType[]): string
Function builds REST API path identifier for multicolumn key. It takes array of values and if a value is string then escapes it, otherwise converts to string and separates them with '_'
Parameters
Name | Meaning |
---|---|
ids | array of identifiers |