Files
twenty/packages/twenty-server/src/engine/workspace-manager/demo-objects-prefill-data/person.ts
Félix Malfait 9aa24ed803 Compile with swc on twenty-server (#4863)
Experiment using swc instead of tsc (as we did the switch on
twenty-front)

It's **much** faster (at least 5x) but has stricter requirements.
I fixed the build but there's still an error while starting the server,
opening this PR for discussion.

Checkout the branch and try `nx build:swc twenty-server`

Read: https://docs.nestjs.com/recipes/swc#common-pitfalls
2024-04-14 09:09:51 +02:00

45 lines
1.1 KiB
TypeScript

import { EntityManager } from 'typeorm';
import { peopleDemo } from 'src/engine/workspace-manager/demo-objects-prefill-data/people-demo.json';
export const personPrefillDemoData = async (
entityManager: EntityManager,
schemaName: string,
) => {
const companies = await entityManager?.query(
`SELECT * FROM ${schemaName}.company`,
);
// Iterate through the array and add a UUID for each person
const people = peopleDemo.map((person, index) => ({
nameFirstName: person.firstName,
nameLastName: person.lastName,
email: person.email,
linkedinLinkUrl: person.linkedinUrl,
jobTitle: person.jobTitle,
city: person.city,
avatarUrl: person.avatarUrl,
position: index,
companyId: companies[Math.floor(index / 2)].id,
}));
await entityManager
.createQueryBuilder()
.insert()
.into(`${schemaName}.person`, [
'nameFirstName',
'nameLastName',
'email',
'linkedinLinkUrl',
'jobTitle',
'city',
'avatarUrl',
'position',
'companyId',
])
.orIgnore()
.values(people)
.returning('*')
.execute();
};