@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
26 lines (17 loc) • 1.15 kB
Markdown
lang: en
title: 'API docs: repository.hasmanydefinition.keyto'
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.hasmanydefinition.keyto.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/repository](./repository.md) > [HasManyDefinition](./repository.hasmanydefinition.md) > [keyTo](./repository.hasmanydefinition.keyto.md)
## HasManyDefinition.keyTo property
keyTo: The foreign key used by the target model for this relation. keyFrom: The source key used by the source model for this relation.
E.g. when a Customer has many Order instances, 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".
<b>Signature:</b>
```typescript
keyTo?: string;
```