Seeking assistance with a programming issue I've been grappling with. Despite extensive research online, I haven't been able to find a solution. As someone new to coding, I would greatly appreciate guidance.
The specific task at hand involves establishing a 1-n relationship. The "1" corresponds to the Business entity, whereas the "n" pertains to data extracted from an array of objects.
My objectives are as follows:
- Set up the Business entity
- Create Trading Entities and associate them with the Business. Each Trading Entity's name should be derived from BN_NAME, while its status should originate from BN_STATUS.
While I am currently utilizing NestJS, any support in TypeScript would be invaluable for my learning process.
Thank you in advance for your help.
-Paul
Below is the schema I am working with:
model Business {
id Int @id @default(autoincrement())
BN_ABN Int? @unique
tradingEntities TradingEntity[]
}
model TradingEntity {
id Int @id @default(autoincrement())
Business Business @relation(fields: [BusinessId], references: [id])
BusinessId Int
Name String // BN_NAME from array of objects
Status String // BN_STATUS from array of objects
}
Here is the array of objects:
[
{
_id: 1812602,
REGISTER_NAME: 'BUSINESS NAMES',
BN_NAME: 'Synergy Evolved',
BN_STATUS: 'Registered',
BN_REG_DT: '08/09/2012',
BN_CANCEL_DT: null,
BN_RENEW_DT: '08/09/2021',
BN_STATE_NUM: null,
BN_STATE_OF_REG: null,
BN_ABN: '48166724204',
rank: 0.0573088
},
{
_id: 2199676,
REGISTER_NAME: 'BUSINESS NAMES',
BN_NAME: 'VALUERACK',
BN_STATUS: 'Registered',
BN_REG_DT: '11/04/2012',
BN_CANCEL_DT: null,
BN_RENEW_DT: '11/04/2015',
BN_STATE_NUM: 'B2460084Y',
BN_STATE_OF_REG: 'VIC',
BN_ABN: '48166724204',
rank: 0.0573088
}
]