Improve provisionning new accounts (#757)
* Improve provisionning new accounts * Fix lint
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { PrismaService } from 'src/database/prisma.service';
|
||||
import companiesSeed from 'src/core/company/seed-data/companies.json';
|
||||
|
||||
@Injectable()
|
||||
export class CompanyService {
|
||||
@ -36,4 +37,15 @@ export class CompanyService {
|
||||
|
||||
// GroupBy
|
||||
groupBy = this.prismaService.company.groupBy;
|
||||
async createDefaultCompanies({ workspaceId }: { workspaceId: string }) {
|
||||
const companies = companiesSeed.map((company) => ({
|
||||
...company,
|
||||
workspaceId,
|
||||
}));
|
||||
await this.createMany({
|
||||
data: companies,
|
||||
});
|
||||
|
||||
return this.findMany({ where: { workspaceId }});
|
||||
}
|
||||
}
|
||||
|
||||
33
server/src/core/company/seed-data/companies.json
Normal file
33
server/src/core/company/seed-data/companies.json
Normal file
@ -0,0 +1,33 @@
|
||||
[
|
||||
{
|
||||
"name": "Rudderstack",
|
||||
"domainName": "rudderstack.com",
|
||||
"address": "San Francisco",
|
||||
"employees": 195
|
||||
},
|
||||
{
|
||||
"name": "Medusa",
|
||||
"domainName": "medusajs.com",
|
||||
"address": "Copenhagen",
|
||||
"employees": 57
|
||||
},
|
||||
{
|
||||
"name": "Metabase",
|
||||
"domainName": "metabase.com",
|
||||
"address": "San Francisco",
|
||||
"employees": 68
|
||||
},
|
||||
{
|
||||
"name": "Strapi",
|
||||
"domainName": "strapi.com",
|
||||
"address": "Paris",
|
||||
"employees": 95
|
||||
},
|
||||
{
|
||||
"name": "Posthog",
|
||||
"domainName": "posthog.com",
|
||||
"address": "San Francisco",
|
||||
"employees": 34
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user