UNPKG

@loopback/docs

Version:

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

34 lines (24 loc) 2.16 kB
--- lang: en title: 'API docs: repository.hasonedefinition' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/repository permalink: /doc/en/lb4/apidocs.repository.hasonedefinition.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [HasOneDefinition](./repository.hasonedefinition.md) ## HasOneDefinition interface **Signature:** ```typescript export interface HasOneDefinition extends RelationDefinitionBase ``` **Extends:** [RelationDefinitionBase](./repository.relationdefinitionbase.md) ## Properties | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [keyFrom?](./repository.hasonedefinition.keyfrom.md) | | string | _(Optional)_ | | [keyTo?](./repository.hasonedefinition.keyto.md) | | string | <p>_(Optional)_ keyTo: The foreign key used by the target model for this relation. keyFrom: The source key used by the source model for this relation.</p><p>E.g. when a Customer has one Address instance, then keyTo is "customerId". Note that "customerId" is the default FK assumed by the framework, users can provide a custom FK name by setting "keyTo". And Customer.id is keyFrom. keyFrom defaults to the id property of a model. Users can provide a custom source key name by setting "keyTo".</p> | | [polymorphic?](./repository.hasonedefinition.polymorphic.md) | | boolean \| { discriminator: string; } | _(Optional)_ The polymorphism of the target model. The discriminator is a key of source model. If the target model is not polymorphic, then the value should be left undefined or false; If the key on source model indicating the concrete class of the target instance is default i.e. camelCase(classNameOf(throughModelInstance)) + "Id" Then the discriminator field can be undefined | | [targetsMany](./repository.hasonedefinition.targetsmany.md) | | false | | | [type](./repository.hasonedefinition.type.md) | | [RelationType.hasOne](./repository.relationtype.md) | |