UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

90 lines (47 loc) 1.6 kB
--- lang: en title: 'API docs: context.bindingkey.create' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/context permalink: /doc/en/lb4/apidocs.context.bindingkey.create.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [BindingKey](./context.bindingkey.md) &gt; [create](./context.bindingkey.create.md) ## BindingKey.create() method Create a new key for a binding bound to a value of type `ValueType`<!-- -->. **Signature:** ```typescript static create<V>(key: string, propertyPath?: string): BindingKey<V>; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> key </td><td markdown="1"> string </td><td markdown="1"> The binding key. When propertyPath is not provided, the key is allowed to contain propertyPath as encoded via `BindingKey#toString()` </td></tr> <tr><td markdown="1"> propertyPath </td><td markdown="1"> string </td><td markdown="1"> _(Optional)_ Optional path to a deep property of the bound value. </td></tr> </tbody></table> **Returns:** [BindingKey](./context.bindingkey.md)<!-- -->&lt;V&gt; ## Example ```ts BindingKey.create<string>('application.name'); BindingKey.create<number>('config', 'rest.port); BindingKey.create<number>('config#rest.port'); ```