1753 lines
41 KiB
JavaScript
1753 lines
41 KiB
JavaScript
const db = require('../models');
|
||
const Users = db.users;
|
||
|
||
const Activities = db.activities;
|
||
|
||
const Attachments = db.attachments;
|
||
|
||
const Clients = db.clients;
|
||
|
||
const Deals = db.deals;
|
||
|
||
const Leads = db.leads;
|
||
|
||
const Notes = db.notes;
|
||
|
||
const Organizations = db.organizations;
|
||
|
||
const Products = db.products;
|
||
|
||
const Organização = db.organização;
|
||
|
||
const ActivitiesData = [
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'PROPOSTA',
|
||
|
||
title: 'No one tells me shit',
|
||
|
||
detailed_description:
|
||
'Much to learn you still have my old padawan. ... This is just the beginning!',
|
||
|
||
action_datetime: new Date('2025-03-27'),
|
||
|
||
duration: 2,
|
||
|
||
outcome: "That's messed up",
|
||
|
||
next_steps: 'Turd gone wrong',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "files" field
|
||
|
||
location: "Y'all never listen to me",
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'LIGACAO',
|
||
|
||
title: "Goin' hog huntin'",
|
||
|
||
detailed_description:
|
||
'Size matters not. Look at me. Judge me by my size, do you? Hmm? Hmm. And well you should not. For my ally is the Force, and a powerful ally it is. Life creates it, makes it grow. Its energy surrounds us and binds us. Luminous beings are we, not this crude matter. You must feel the Force around you; here, between you, me, the tree, the rock, everywhere, yes. Even between the land and the ship.',
|
||
|
||
action_datetime: new Date('2024-09-21'),
|
||
|
||
duration: 6,
|
||
|
||
outcome: 'My boss gonna fire me',
|
||
|
||
next_steps: 'Standby',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "files" field
|
||
|
||
location: 'My boss gonna fire me',
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'VISITA',
|
||
|
||
title: 'That goddamn Datamate',
|
||
|
||
detailed_description:
|
||
'Always two there are, no more, no less. A master and an apprentice.',
|
||
|
||
action_datetime: new Date('2025-04-09'),
|
||
|
||
duration: 6,
|
||
|
||
outcome: "That Barbala couldn't fly his way out of a wet paper bag",
|
||
|
||
next_steps: 'Yup',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "files" field
|
||
|
||
location: 'Like a red-headed stepchild',
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'WHATSAPP',
|
||
|
||
title: 'Texas!',
|
||
|
||
detailed_description:
|
||
'Adventure. Excitement. A Jedi craves not these things.',
|
||
|
||
action_datetime: new Date('2025-03-11'),
|
||
|
||
duration: 1,
|
||
|
||
outcome: 'Come on now',
|
||
|
||
next_steps: 'Standby',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "files" field
|
||
|
||
location: 'Standby',
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'PROPOSTA',
|
||
|
||
title: 'So I was walking Oscar',
|
||
|
||
detailed_description: 'Difficult to see. Always in motion is the future...',
|
||
|
||
action_datetime: new Date('2024-09-27'),
|
||
|
||
duration: 3,
|
||
|
||
outcome: 'That damn gimble',
|
||
|
||
next_steps: 'That damn gimble',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "files" field
|
||
|
||
location: 'Standby',
|
||
},
|
||
];
|
||
|
||
const AttachmentsData = [
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
file_name: 'Contact the tower',
|
||
|
||
file_type: 'Texas!',
|
||
|
||
file_url: 'Always the last one to the party',
|
||
|
||
size: 40.18,
|
||
|
||
upload_date: new Date('2024-09-02'),
|
||
|
||
// type code here for "relation_one" field
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
file_name: 'Contact the tower',
|
||
|
||
file_type: 'That goddamn Datamate',
|
||
|
||
file_url: "Goin' hog huntin'",
|
||
|
||
size: 56.69,
|
||
|
||
upload_date: new Date('2024-11-17'),
|
||
|
||
// type code here for "relation_one" field
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
file_name: 'Texas!',
|
||
|
||
file_type: 'Might be DQ time',
|
||
|
||
file_url: "C'mon Naomi",
|
||
|
||
size: 42.21,
|
||
|
||
upload_date: new Date('2024-12-02'),
|
||
|
||
// type code here for "relation_one" field
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
file_name: 'Yup',
|
||
|
||
file_type: 'Come on now',
|
||
|
||
file_url: 'Reminds me of my old girlfriend Olga Goodntight',
|
||
|
||
size: 58.75,
|
||
|
||
upload_date: new Date('2024-09-11'),
|
||
|
||
// type code here for "relation_one" field
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
file_name: 'Reminds me of my old girlfriend Olga Goodntight',
|
||
|
||
file_type: 'Texas!',
|
||
|
||
file_url: 'Reminds me of my old girlfriend Olga Goodntight',
|
||
|
||
size: 53.69,
|
||
|
||
upload_date: new Date('2024-11-25'),
|
||
|
||
// type code here for "relation_one" field
|
||
},
|
||
];
|
||
|
||
const ClientsData = [
|
||
{
|
||
name: 'Carl Gauss (Karl Friedrich Gauss)',
|
||
|
||
type: 'GovernoEstadual',
|
||
|
||
cnpj_cpf: 'I got that scurvy',
|
||
|
||
primary_email: 'So I was walking Oscar',
|
||
|
||
primary_phone: 'Reminds me of my old girlfriend Olga Goodntight',
|
||
|
||
full_address: 'Younglings, younglings gather ’round.',
|
||
|
||
city: "How 'bout them Cowboys",
|
||
|
||
state: 'I want my damn cart back',
|
||
|
||
postal_code: 'That damn diabetes',
|
||
|
||
contact_person: 'No one tells me shit',
|
||
|
||
registration_date: new Date('2025-01-27'),
|
||
|
||
last_interaction_date: new Date('2024-08-14'),
|
||
|
||
status: 'active',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Hmm. In the end, cowards are those who follow the dark side.',
|
||
|
||
contract_end_date: new Date('2025-04-08'),
|
||
|
||
current_contract_value: 46.05,
|
||
|
||
custom_fields: 'Truly wonderful, the mind of a child is.',
|
||
},
|
||
|
||
{
|
||
name: 'Marie Curie',
|
||
|
||
type: 'Prefeitura',
|
||
|
||
cnpj_cpf: 'Standby',
|
||
|
||
primary_email: "That's messed up",
|
||
|
||
primary_phone: "How 'bout them Cowboys",
|
||
|
||
full_address: 'Adventure. Excitement. A Jedi craves not these things.',
|
||
|
||
city: "That Barbala couldn't fly his way out of a wet paper bag",
|
||
|
||
state: 'No one tells me shit',
|
||
|
||
postal_code: 'My boss gonna fire me',
|
||
|
||
contact_person: 'My buddy Harlen',
|
||
|
||
registration_date: new Date('2025-02-07'),
|
||
|
||
last_interaction_date: new Date('2024-08-19'),
|
||
|
||
status: 'active',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Always pass on what you have learned.',
|
||
|
||
contract_end_date: new Date('2024-08-12'),
|
||
|
||
current_contract_value: 48.12,
|
||
|
||
custom_fields: 'Truly wonderful, the mind of a child is.',
|
||
},
|
||
|
||
{
|
||
name: 'Murray Gell-Mann',
|
||
|
||
type: 'Empresa',
|
||
|
||
cnpj_cpf: 'I tell you what',
|
||
|
||
primary_email: 'Texas!',
|
||
|
||
primary_phone: 'I got that scurvy',
|
||
|
||
full_address: 'Use your feelings, Obi-Wan, and find him you will.',
|
||
|
||
city: 'My buddy Harlen',
|
||
|
||
state: 'Come on now',
|
||
|
||
postal_code: "That's messed up",
|
||
|
||
contact_person: "That's messed up",
|
||
|
||
registration_date: new Date('2025-04-27'),
|
||
|
||
last_interaction_date: new Date('2024-08-20'),
|
||
|
||
status: 'inactive',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Luminous beings are we - not this crude matter.',
|
||
|
||
contract_end_date: new Date('2024-09-21'),
|
||
|
||
current_contract_value: 82.19,
|
||
|
||
custom_fields: 'Difficult to see. Always in motion is the future...',
|
||
},
|
||
|
||
{
|
||
name: 'Arthur Eddington',
|
||
|
||
type: 'GovernoFederal',
|
||
|
||
cnpj_cpf: 'That damn Bill Stull',
|
||
|
||
primary_email: 'I want my damn cart back',
|
||
|
||
primary_phone: 'My boss gonna fire me',
|
||
|
||
full_address:
|
||
'Clear your mind must be, if you are to find the villains behind this plot.',
|
||
|
||
city: "It's around here somewhere",
|
||
|
||
state: "That Barbala couldn't fly his way out of a wet paper bag",
|
||
|
||
postal_code: "I'm washing my hands of it",
|
||
|
||
contact_person: "That's messed up",
|
||
|
||
registration_date: new Date('2025-03-06'),
|
||
|
||
last_interaction_date: new Date('2024-12-11'),
|
||
|
||
status: 'inactive',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Already know you that which you need.',
|
||
|
||
contract_end_date: new Date('2025-04-10'),
|
||
|
||
current_contract_value: 93.11,
|
||
|
||
custom_fields: 'That is why you fail.',
|
||
},
|
||
|
||
{
|
||
name: 'Alfred Wegener',
|
||
|
||
type: 'Entidade',
|
||
|
||
cnpj_cpf: 'Like a red-headed stepchild',
|
||
|
||
primary_email: 'I tell you what',
|
||
|
||
primary_phone: 'That damn Bill Stull',
|
||
|
||
full_address: 'Ow, ow, OW! On my ear you are!',
|
||
|
||
city: "It's around here somewhere",
|
||
|
||
state: "That's messed up",
|
||
|
||
postal_code: 'That damn diabetes',
|
||
|
||
contact_person: 'My boss gonna fire me',
|
||
|
||
registration_date: new Date('2024-11-02'),
|
||
|
||
last_interaction_date: new Date('2024-09-21'),
|
||
|
||
status: 'active',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'That is why you fail.',
|
||
|
||
contract_end_date: new Date('2025-03-04'),
|
||
|
||
current_contract_value: 58.19,
|
||
|
||
custom_fields: 'Younglings, younglings gather ’round.',
|
||
},
|
||
];
|
||
|
||
const DealsData = [
|
||
{
|
||
deal_name: "That's messed up",
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
current_phase: 'PROPOSTA',
|
||
|
||
proposal_value: 45.52,
|
||
|
||
last_modified: new Date('2024-11-23'),
|
||
|
||
phase_entry_dates: 'Luminous beings are we - not this crude matter.',
|
||
|
||
closure_probability: 8,
|
||
|
||
expected_closure_date: new Date('2025-01-12'),
|
||
|
||
status: 'active',
|
||
|
||
loss_pause_reason: "Goin' hog huntin'",
|
||
|
||
latitude: 53.45,
|
||
|
||
longitude: 96.88,
|
||
|
||
deal_address:
|
||
'Always two there are, no more, no less. A master and an apprentice.',
|
||
|
||
general_notes:
|
||
'Strong is Vader. Mind what you have learned. Save you it can.',
|
||
|
||
competitor_name: 'Always the last one to the party',
|
||
|
||
competitor_contract_end_date: new Date('2024-10-22'),
|
||
|
||
custom_fields:
|
||
'Pain, suffering, death I feel. Something terrible has happened. Young Skywalker is in pain. Terrible pain',
|
||
},
|
||
|
||
{
|
||
deal_name: 'That damn Bill Stull',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
current_phase: 'GANHO',
|
||
|
||
proposal_value: 89.72,
|
||
|
||
last_modified: new Date('2025-01-31'),
|
||
|
||
phase_entry_dates:
|
||
'Through the Force, things you will see. Other places. The future - the past. Old friends long gone.',
|
||
|
||
closure_probability: 6,
|
||
|
||
expected_closure_date: new Date('2024-12-20'),
|
||
|
||
status: 'active',
|
||
|
||
loss_pause_reason: 'Reminds me of my old girlfriend Olga Goodntight',
|
||
|
||
latitude: 62.11,
|
||
|
||
longitude: 41.51,
|
||
|
||
deal_address: 'Younglings, younglings gather ’round.',
|
||
|
||
general_notes:
|
||
'Always two there are, no more, no less. A master and an apprentice.',
|
||
|
||
competitor_name: 'That goddamn Datamate',
|
||
|
||
competitor_contract_end_date: new Date('2024-11-03'),
|
||
|
||
custom_fields: 'At an end your rule is, and not short enough it was!',
|
||
},
|
||
|
||
{
|
||
deal_name: "Y'all never listen to me",
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
current_phase: 'RECURSO',
|
||
|
||
proposal_value: 13.28,
|
||
|
||
last_modified: new Date('2024-10-16'),
|
||
|
||
phase_entry_dates:
|
||
'Always two there are, no more, no less. A master and an apprentice.',
|
||
|
||
closure_probability: 9,
|
||
|
||
expected_closure_date: new Date('2025-03-08'),
|
||
|
||
status: 'won',
|
||
|
||
loss_pause_reason: 'Contact the tower',
|
||
|
||
latitude: 36.49,
|
||
|
||
longitude: 25.32,
|
||
|
||
deal_address: 'That is why you fail.',
|
||
|
||
general_notes: 'Use your feelings, Obi-Wan, and find him you will.',
|
||
|
||
competitor_name: 'Got depression, Smith and Wessen',
|
||
|
||
competitor_contract_end_date: new Date('2025-01-20'),
|
||
|
||
custom_fields:
|
||
'Pain, suffering, death I feel. Something terrible has happened. Young Skywalker is in pain. Terrible pain',
|
||
},
|
||
|
||
{
|
||
deal_name: 'Reminds me of my old girlfriend Olga Goodntight',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
current_phase: 'PRELANÇAMENTO',
|
||
|
||
proposal_value: 40.02,
|
||
|
||
last_modified: new Date('2024-11-16'),
|
||
|
||
phase_entry_dates:
|
||
'Like fire across the galaxy the Clone Wars spread. In league with the wicked Count Dooku, more and more planets slip. Against this threat, upon the Jedi Knights falls the duty to lead the newly formed army of the Republic. And as the heat of war grows, so, to, grows the prowess of one most gifted student of the Force.',
|
||
|
||
closure_probability: 6,
|
||
|
||
expected_closure_date: new Date('2024-08-24'),
|
||
|
||
status: 'active',
|
||
|
||
loss_pause_reason: "Goin' hog huntin'",
|
||
|
||
latitude: 45.38,
|
||
|
||
longitude: 64.81,
|
||
|
||
deal_address: 'You will find only what you bring in.',
|
||
|
||
general_notes: 'Adventure. Excitement. A Jedi craves not these things.',
|
||
|
||
competitor_name: 'Yup',
|
||
|
||
competitor_contract_end_date: new Date('2025-01-13'),
|
||
|
||
custom_fields: 'Younglings, younglings gather ’round.',
|
||
},
|
||
|
||
{
|
||
deal_name: 'Turd gone wrong',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
current_phase: 'LEAD',
|
||
|
||
proposal_value: 80.09,
|
||
|
||
last_modified: new Date('2025-02-24'),
|
||
|
||
phase_entry_dates: 'You will find only what you bring in.',
|
||
|
||
closure_probability: 6,
|
||
|
||
expected_closure_date: new Date('2024-10-08'),
|
||
|
||
status: 'won',
|
||
|
||
loss_pause_reason: 'Might be DQ time',
|
||
|
||
latitude: 76.38,
|
||
|
||
longitude: 94.57,
|
||
|
||
deal_address:
|
||
'Death is a natural part of life. Rejoice for those around you who transform into the Force. Mourn them do not. Miss them do not. Attachment leads to jealously. The shadow of greed, that is.',
|
||
|
||
general_notes: 'Reckless he is. Matters are worse.',
|
||
|
||
competitor_name: 'I tell you what',
|
||
|
||
competitor_contract_end_date: new Date('2024-07-29'),
|
||
|
||
custom_fields: 'Your weapons, you will not need them.',
|
||
},
|
||
];
|
||
|
||
const LeadsData = [
|
||
{
|
||
name: 'Christiaan Huygens',
|
||
|
||
type: 'Empresa',
|
||
|
||
email: 'rob_renner@mcdermott.test',
|
||
|
||
phone: '714 797 8337',
|
||
|
||
city: "How 'bout them Cowboys",
|
||
|
||
state: 'Like a red-headed stepchild',
|
||
|
||
lead_source: "Goin' hog huntin'",
|
||
|
||
registration_date: new Date('2025-05-27'),
|
||
|
||
status: 'active',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Truly wonderful, the mind of a child is.',
|
||
|
||
score: 7,
|
||
|
||
last_contact: new Date('2024-11-20'),
|
||
|
||
custom_fields: 'Luminous beings are we - not this crude matter.',
|
||
},
|
||
|
||
{
|
||
name: 'John Dalton',
|
||
|
||
type: 'GovernoFederal',
|
||
|
||
email: 'candida@beer.example',
|
||
|
||
phone: '247 123 7443',
|
||
|
||
city: 'Turd gone wrong',
|
||
|
||
state: 'That damn diabetes',
|
||
|
||
lead_source: 'Always the last one to the party',
|
||
|
||
registration_date: new Date('2024-11-03'),
|
||
|
||
status: 'converted',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Feel the force!',
|
||
|
||
score: 6,
|
||
|
||
last_contact: new Date('2025-04-25'),
|
||
|
||
custom_fields:
|
||
'Through the Force, things you will see. Other places. The future - the past. Old friends long gone.',
|
||
},
|
||
|
||
{
|
||
name: 'Pierre Simon de Laplace',
|
||
|
||
type: 'GovernoFederal',
|
||
|
||
email: 'flo.mckenzie@trantow.test',
|
||
|
||
phone: '6012456863',
|
||
|
||
city: 'Let me tell ya',
|
||
|
||
state: "I'm washing my hands of it",
|
||
|
||
lead_source: 'That damn Bill Stull',
|
||
|
||
registration_date: new Date('2024-12-08'),
|
||
|
||
status: 'discarded',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Strong is Vader. Mind what you have learned. Save you it can.',
|
||
|
||
score: 4,
|
||
|
||
last_contact: new Date('2025-01-28'),
|
||
|
||
custom_fields:
|
||
'Clear your mind must be, if you are to find the villains behind this plot.',
|
||
},
|
||
|
||
{
|
||
name: 'Ernst Haeckel',
|
||
|
||
type: 'Entidade',
|
||
|
||
email: 'dakota.parker@collier.example',
|
||
|
||
phone: '981.979.2468',
|
||
|
||
city: 'That damn diabetes',
|
||
|
||
state: 'So I was walking Oscar',
|
||
|
||
lead_source: "Goin' hog huntin'",
|
||
|
||
registration_date: new Date('2025-05-27'),
|
||
|
||
status: 'converted',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Good relations with the Wookiees, I have.',
|
||
|
||
score: 7,
|
||
|
||
last_contact: new Date('2025-05-31'),
|
||
|
||
custom_fields:
|
||
'Always two there are, no more, no less. A master and an apprentice.',
|
||
},
|
||
|
||
{
|
||
name: 'Paul Ehrlich',
|
||
|
||
type: 'Entidade',
|
||
|
||
email: 'ashley@greenholt.example',
|
||
|
||
phone: '534 714 8074',
|
||
|
||
city: 'So I was walking Oscar',
|
||
|
||
state: 'That goddamn Datamate',
|
||
|
||
lead_source: 'Texas!',
|
||
|
||
registration_date: new Date('2024-09-04'),
|
||
|
||
status: 'active',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
notes: 'Use your feelings, Obi-Wan, and find him you will.',
|
||
|
||
score: 1,
|
||
|
||
last_contact: new Date('2024-06-19'),
|
||
|
||
custom_fields: 'Luminous beings are we - not this crude matter.',
|
||
},
|
||
];
|
||
|
||
const NotesData = [
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
content: 'Mudhole? Slimy? My home this is!',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'important',
|
||
|
||
color_category: 'Yup',
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
content: 'Younglings, younglings gather ’round.',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'important',
|
||
|
||
color_category: 'Like a red-headed stepchild',
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
content: 'Luminous beings are we - not this crude matter.',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'general',
|
||
|
||
color_category: 'Got depression, Smith and Wessen',
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
content:
|
||
'Do not assume anything Obi-Wan. Clear your mind must be if you are to discover the real villains behind this plot.',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'important',
|
||
|
||
color_category: 'Let me tell ya',
|
||
},
|
||
|
||
{
|
||
// type code here for "relation_one" field
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
content:
|
||
'Clear your mind must be, if you are to find the villains behind this plot.',
|
||
|
||
// type code here for "relation_one" field
|
||
|
||
type: 'reminder',
|
||
|
||
color_category: 'I got that scurvy',
|
||
},
|
||
];
|
||
|
||
const OrganizationsData = [
|
||
{
|
||
name: 'Comte de Buffon',
|
||
|
||
description:
|
||
'Yes, a Jedi’s strength flows from the Force. But beware of the dark side. Anger, fear, aggression; the dark side of the Force are they. Easily they flow, quick to join you in a fight. If once you start down the dark path, forever will it dominate your destiny, consume you it will, as it did Obi-Wan’s apprentice.',
|
||
|
||
// type code here for "relation_many" field
|
||
},
|
||
|
||
{
|
||
name: 'Nicolaus Copernicus',
|
||
|
||
description: 'Ow, ow, OW! On my ear you are!',
|
||
|
||
// type code here for "relation_many" field
|
||
},
|
||
|
||
{
|
||
name: 'Andreas Vesalius',
|
||
|
||
description:
|
||
'Through the Force, things you will see. Other places. The future - the past. Old friends long gone.',
|
||
|
||
// type code here for "relation_many" field
|
||
},
|
||
|
||
{
|
||
name: 'Linus Pauling',
|
||
|
||
description: 'Around the survivors a perimeter create.',
|
||
|
||
// type code here for "relation_many" field
|
||
},
|
||
|
||
{
|
||
name: 'Louis Pasteur',
|
||
|
||
description: 'Around the survivors a perimeter create.',
|
||
|
||
// type code here for "relation_many" field
|
||
},
|
||
];
|
||
|
||
const ProductsData = [
|
||
{
|
||
product_name: "C'mon Naomi",
|
||
|
||
description: 'Reckless he is. Matters are worse.',
|
||
|
||
category: 'I tell you what',
|
||
|
||
base_price: 83.54,
|
||
|
||
status: 'active',
|
||
},
|
||
|
||
{
|
||
product_name: "Y'all never listen to me",
|
||
|
||
description:
|
||
'Soon will I rest, yes, forever sleep. Earned it I have. Twilight is upon me, soon night must fall.',
|
||
|
||
category: 'Always the last one to the party',
|
||
|
||
base_price: 56.75,
|
||
|
||
status: 'inactive',
|
||
},
|
||
|
||
{
|
||
product_name: 'I got that scurvy',
|
||
|
||
description: 'Around the survivors a perimeter create.',
|
||
|
||
category: 'Turd gone wrong',
|
||
|
||
base_price: 71.75,
|
||
|
||
status: 'inactive',
|
||
},
|
||
|
||
{
|
||
product_name: 'That goddamn Datamate',
|
||
|
||
description:
|
||
'Strong is Vader. Mind what you have learned. Save you it can.',
|
||
|
||
category: 'I got that scurvy',
|
||
|
||
base_price: 71.83,
|
||
|
||
status: 'active',
|
||
},
|
||
|
||
{
|
||
product_name: 'Standby',
|
||
|
||
description:
|
||
'Pain, suffering, death I feel. Something terrible has happened. Young Skywalker is in pain. Terrible pain',
|
||
|
||
category: 'Standby',
|
||
|
||
base_price: 54.34,
|
||
|
||
status: 'inactive',
|
||
},
|
||
];
|
||
|
||
const OrganizaçãoData = [
|
||
{
|
||
name: 'Max Planck',
|
||
},
|
||
|
||
{
|
||
name: 'Gertrude Belle Elion',
|
||
},
|
||
|
||
{
|
||
name: 'Enrico Fermi',
|
||
},
|
||
|
||
{
|
||
name: 'Anton van Leeuwenhoek',
|
||
},
|
||
|
||
{
|
||
name: 'Hermann von Helmholtz',
|
||
},
|
||
];
|
||
|
||
// Similar logic for "relation_many"
|
||
|
||
async function associateActivityWithDeal() {
|
||
const relatedDeal0 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Activity0 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Activity0?.setDeal) {
|
||
await Activity0.setDeal(relatedDeal0);
|
||
}
|
||
|
||
const relatedDeal1 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Activity1 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Activity1?.setDeal) {
|
||
await Activity1.setDeal(relatedDeal1);
|
||
}
|
||
|
||
const relatedDeal2 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Activity2 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Activity2?.setDeal) {
|
||
await Activity2.setDeal(relatedDeal2);
|
||
}
|
||
|
||
const relatedDeal3 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Activity3 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Activity3?.setDeal) {
|
||
await Activity3.setDeal(relatedDeal3);
|
||
}
|
||
|
||
const relatedDeal4 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Activity4 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Activity4?.setDeal) {
|
||
await Activity4.setDeal(relatedDeal4);
|
||
}
|
||
}
|
||
|
||
async function associateActivityWithResponsible_seller() {
|
||
const relatedResponsible_seller0 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Activity0 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Activity0?.setResponsible_seller) {
|
||
await Activity0.setResponsible_seller(relatedResponsible_seller0);
|
||
}
|
||
|
||
const relatedResponsible_seller1 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Activity1 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Activity1?.setResponsible_seller) {
|
||
await Activity1.setResponsible_seller(relatedResponsible_seller1);
|
||
}
|
||
|
||
const relatedResponsible_seller2 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Activity2 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Activity2?.setResponsible_seller) {
|
||
await Activity2.setResponsible_seller(relatedResponsible_seller2);
|
||
}
|
||
|
||
const relatedResponsible_seller3 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Activity3 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Activity3?.setResponsible_seller) {
|
||
await Activity3.setResponsible_seller(relatedResponsible_seller3);
|
||
}
|
||
|
||
const relatedResponsible_seller4 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Activity4 = await Activities.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Activity4?.setResponsible_seller) {
|
||
await Activity4.setResponsible_seller(relatedResponsible_seller4);
|
||
}
|
||
}
|
||
|
||
async function associateAttachmentWithActivity() {
|
||
const relatedActivity0 = await Activities.findOne({
|
||
offset: Math.floor(Math.random() * (await Activities.count())),
|
||
});
|
||
const Attachment0 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Attachment0?.setActivity) {
|
||
await Attachment0.setActivity(relatedActivity0);
|
||
}
|
||
|
||
const relatedActivity1 = await Activities.findOne({
|
||
offset: Math.floor(Math.random() * (await Activities.count())),
|
||
});
|
||
const Attachment1 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Attachment1?.setActivity) {
|
||
await Attachment1.setActivity(relatedActivity1);
|
||
}
|
||
|
||
const relatedActivity2 = await Activities.findOne({
|
||
offset: Math.floor(Math.random() * (await Activities.count())),
|
||
});
|
||
const Attachment2 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Attachment2?.setActivity) {
|
||
await Attachment2.setActivity(relatedActivity2);
|
||
}
|
||
|
||
const relatedActivity3 = await Activities.findOne({
|
||
offset: Math.floor(Math.random() * (await Activities.count())),
|
||
});
|
||
const Attachment3 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Attachment3?.setActivity) {
|
||
await Attachment3.setActivity(relatedActivity3);
|
||
}
|
||
|
||
const relatedActivity4 = await Activities.findOne({
|
||
offset: Math.floor(Math.random() * (await Activities.count())),
|
||
});
|
||
const Attachment4 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Attachment4?.setActivity) {
|
||
await Attachment4.setActivity(relatedActivity4);
|
||
}
|
||
}
|
||
|
||
async function associateAttachmentWithUploaded_by() {
|
||
const relatedUploaded_by0 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Attachment0 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Attachment0?.setUploaded_by) {
|
||
await Attachment0.setUploaded_by(relatedUploaded_by0);
|
||
}
|
||
|
||
const relatedUploaded_by1 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Attachment1 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Attachment1?.setUploaded_by) {
|
||
await Attachment1.setUploaded_by(relatedUploaded_by1);
|
||
}
|
||
|
||
const relatedUploaded_by2 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Attachment2 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Attachment2?.setUploaded_by) {
|
||
await Attachment2.setUploaded_by(relatedUploaded_by2);
|
||
}
|
||
|
||
const relatedUploaded_by3 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Attachment3 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Attachment3?.setUploaded_by) {
|
||
await Attachment3.setUploaded_by(relatedUploaded_by3);
|
||
}
|
||
|
||
const relatedUploaded_by4 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Attachment4 = await Attachments.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Attachment4?.setUploaded_by) {
|
||
await Attachment4.setUploaded_by(relatedUploaded_by4);
|
||
}
|
||
}
|
||
|
||
async function associateClientWithResponsible_seller() {
|
||
const relatedResponsible_seller0 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Client0 = await Clients.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Client0?.setResponsible_seller) {
|
||
await Client0.setResponsible_seller(relatedResponsible_seller0);
|
||
}
|
||
|
||
const relatedResponsible_seller1 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Client1 = await Clients.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Client1?.setResponsible_seller) {
|
||
await Client1.setResponsible_seller(relatedResponsible_seller1);
|
||
}
|
||
|
||
const relatedResponsible_seller2 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Client2 = await Clients.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Client2?.setResponsible_seller) {
|
||
await Client2.setResponsible_seller(relatedResponsible_seller2);
|
||
}
|
||
|
||
const relatedResponsible_seller3 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Client3 = await Clients.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Client3?.setResponsible_seller) {
|
||
await Client3.setResponsible_seller(relatedResponsible_seller3);
|
||
}
|
||
|
||
const relatedResponsible_seller4 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Client4 = await Clients.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Client4?.setResponsible_seller) {
|
||
await Client4.setResponsible_seller(relatedResponsible_seller4);
|
||
}
|
||
}
|
||
|
||
async function associateDealWithClient_lead() {
|
||
const relatedClient_lead0 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Deal0 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Deal0?.setClient_lead) {
|
||
await Deal0.setClient_lead(relatedClient_lead0);
|
||
}
|
||
|
||
const relatedClient_lead1 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Deal1 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Deal1?.setClient_lead) {
|
||
await Deal1.setClient_lead(relatedClient_lead1);
|
||
}
|
||
|
||
const relatedClient_lead2 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Deal2 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Deal2?.setClient_lead) {
|
||
await Deal2.setClient_lead(relatedClient_lead2);
|
||
}
|
||
|
||
const relatedClient_lead3 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Deal3 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Deal3?.setClient_lead) {
|
||
await Deal3.setClient_lead(relatedClient_lead3);
|
||
}
|
||
|
||
const relatedClient_lead4 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Deal4 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Deal4?.setClient_lead) {
|
||
await Deal4.setClient_lead(relatedClient_lead4);
|
||
}
|
||
}
|
||
|
||
async function associateDealWithOffered_product() {
|
||
const relatedOffered_product0 = await Products.findOne({
|
||
offset: Math.floor(Math.random() * (await Products.count())),
|
||
});
|
||
const Deal0 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Deal0?.setOffered_product) {
|
||
await Deal0.setOffered_product(relatedOffered_product0);
|
||
}
|
||
|
||
const relatedOffered_product1 = await Products.findOne({
|
||
offset: Math.floor(Math.random() * (await Products.count())),
|
||
});
|
||
const Deal1 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Deal1?.setOffered_product) {
|
||
await Deal1.setOffered_product(relatedOffered_product1);
|
||
}
|
||
|
||
const relatedOffered_product2 = await Products.findOne({
|
||
offset: Math.floor(Math.random() * (await Products.count())),
|
||
});
|
||
const Deal2 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Deal2?.setOffered_product) {
|
||
await Deal2.setOffered_product(relatedOffered_product2);
|
||
}
|
||
|
||
const relatedOffered_product3 = await Products.findOne({
|
||
offset: Math.floor(Math.random() * (await Products.count())),
|
||
});
|
||
const Deal3 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Deal3?.setOffered_product) {
|
||
await Deal3.setOffered_product(relatedOffered_product3);
|
||
}
|
||
|
||
const relatedOffered_product4 = await Products.findOne({
|
||
offset: Math.floor(Math.random() * (await Products.count())),
|
||
});
|
||
const Deal4 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Deal4?.setOffered_product) {
|
||
await Deal4.setOffered_product(relatedOffered_product4);
|
||
}
|
||
}
|
||
|
||
async function associateDealWithResponsible_seller() {
|
||
const relatedResponsible_seller0 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Deal0 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Deal0?.setResponsible_seller) {
|
||
await Deal0.setResponsible_seller(relatedResponsible_seller0);
|
||
}
|
||
|
||
const relatedResponsible_seller1 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Deal1 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Deal1?.setResponsible_seller) {
|
||
await Deal1.setResponsible_seller(relatedResponsible_seller1);
|
||
}
|
||
|
||
const relatedResponsible_seller2 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Deal2 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Deal2?.setResponsible_seller) {
|
||
await Deal2.setResponsible_seller(relatedResponsible_seller2);
|
||
}
|
||
|
||
const relatedResponsible_seller3 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Deal3 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Deal3?.setResponsible_seller) {
|
||
await Deal3.setResponsible_seller(relatedResponsible_seller3);
|
||
}
|
||
|
||
const relatedResponsible_seller4 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Deal4 = await Deals.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Deal4?.setResponsible_seller) {
|
||
await Deal4.setResponsible_seller(relatedResponsible_seller4);
|
||
}
|
||
}
|
||
|
||
async function associateLeadWithResponsible_seller() {
|
||
const relatedResponsible_seller0 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Lead0 = await Leads.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Lead0?.setResponsible_seller) {
|
||
await Lead0.setResponsible_seller(relatedResponsible_seller0);
|
||
}
|
||
|
||
const relatedResponsible_seller1 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Lead1 = await Leads.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Lead1?.setResponsible_seller) {
|
||
await Lead1.setResponsible_seller(relatedResponsible_seller1);
|
||
}
|
||
|
||
const relatedResponsible_seller2 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Lead2 = await Leads.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Lead2?.setResponsible_seller) {
|
||
await Lead2.setResponsible_seller(relatedResponsible_seller2);
|
||
}
|
||
|
||
const relatedResponsible_seller3 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Lead3 = await Leads.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Lead3?.setResponsible_seller) {
|
||
await Lead3.setResponsible_seller(relatedResponsible_seller3);
|
||
}
|
||
|
||
const relatedResponsible_seller4 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Lead4 = await Leads.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Lead4?.setResponsible_seller) {
|
||
await Lead4.setResponsible_seller(relatedResponsible_seller4);
|
||
}
|
||
}
|
||
|
||
async function associateNoteWithDeal() {
|
||
const relatedDeal0 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Note0 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Note0?.setDeal) {
|
||
await Note0.setDeal(relatedDeal0);
|
||
}
|
||
|
||
const relatedDeal1 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Note1 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Note1?.setDeal) {
|
||
await Note1.setDeal(relatedDeal1);
|
||
}
|
||
|
||
const relatedDeal2 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Note2 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Note2?.setDeal) {
|
||
await Note2.setDeal(relatedDeal2);
|
||
}
|
||
|
||
const relatedDeal3 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Note3 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Note3?.setDeal) {
|
||
await Note3.setDeal(relatedDeal3);
|
||
}
|
||
|
||
const relatedDeal4 = await Deals.findOne({
|
||
offset: Math.floor(Math.random() * (await Deals.count())),
|
||
});
|
||
const Note4 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Note4?.setDeal) {
|
||
await Note4.setDeal(relatedDeal4);
|
||
}
|
||
}
|
||
|
||
async function associateNoteWithClient() {
|
||
const relatedClient0 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Note0 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Note0?.setClient) {
|
||
await Note0.setClient(relatedClient0);
|
||
}
|
||
|
||
const relatedClient1 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Note1 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Note1?.setClient) {
|
||
await Note1.setClient(relatedClient1);
|
||
}
|
||
|
||
const relatedClient2 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Note2 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Note2?.setClient) {
|
||
await Note2.setClient(relatedClient2);
|
||
}
|
||
|
||
const relatedClient3 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Note3 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Note3?.setClient) {
|
||
await Note3.setClient(relatedClient3);
|
||
}
|
||
|
||
const relatedClient4 = await Clients.findOne({
|
||
offset: Math.floor(Math.random() * (await Clients.count())),
|
||
});
|
||
const Note4 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Note4?.setClient) {
|
||
await Note4.setClient(relatedClient4);
|
||
}
|
||
}
|
||
|
||
async function associateNoteWithSeller() {
|
||
const relatedSeller0 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Note0 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 0,
|
||
});
|
||
if (Note0?.setSeller) {
|
||
await Note0.setSeller(relatedSeller0);
|
||
}
|
||
|
||
const relatedSeller1 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Note1 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 1,
|
||
});
|
||
if (Note1?.setSeller) {
|
||
await Note1.setSeller(relatedSeller1);
|
||
}
|
||
|
||
const relatedSeller2 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Note2 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 2,
|
||
});
|
||
if (Note2?.setSeller) {
|
||
await Note2.setSeller(relatedSeller2);
|
||
}
|
||
|
||
const relatedSeller3 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Note3 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 3,
|
||
});
|
||
if (Note3?.setSeller) {
|
||
await Note3.setSeller(relatedSeller3);
|
||
}
|
||
|
||
const relatedSeller4 = await Users.findOne({
|
||
offset: Math.floor(Math.random() * (await Users.count())),
|
||
});
|
||
const Note4 = await Notes.findOne({
|
||
order: [['id', 'ASC']],
|
||
offset: 4,
|
||
});
|
||
if (Note4?.setSeller) {
|
||
await Note4.setSeller(relatedSeller4);
|
||
}
|
||
}
|
||
|
||
// Similar logic for "relation_many"
|
||
|
||
module.exports = {
|
||
up: async (queryInterface, Sequelize) => {
|
||
await Activities.bulkCreate(ActivitiesData);
|
||
|
||
await Attachments.bulkCreate(AttachmentsData);
|
||
|
||
await Clients.bulkCreate(ClientsData);
|
||
|
||
await Deals.bulkCreate(DealsData);
|
||
|
||
await Leads.bulkCreate(LeadsData);
|
||
|
||
await Notes.bulkCreate(NotesData);
|
||
|
||
await Organizations.bulkCreate(OrganizationsData);
|
||
|
||
await Products.bulkCreate(ProductsData);
|
||
|
||
await Organização.bulkCreate(OrganizaçãoData);
|
||
|
||
await Promise.all([
|
||
// Similar logic for "relation_many"
|
||
|
||
await associateActivityWithDeal(),
|
||
|
||
await associateActivityWithResponsible_seller(),
|
||
|
||
await associateAttachmentWithActivity(),
|
||
|
||
await associateAttachmentWithUploaded_by(),
|
||
|
||
await associateClientWithResponsible_seller(),
|
||
|
||
await associateDealWithClient_lead(),
|
||
|
||
await associateDealWithOffered_product(),
|
||
|
||
await associateDealWithResponsible_seller(),
|
||
|
||
await associateLeadWithResponsible_seller(),
|
||
|
||
await associateNoteWithDeal(),
|
||
|
||
await associateNoteWithClient(),
|
||
|
||
await associateNoteWithSeller(),
|
||
|
||
// Similar logic for "relation_many"
|
||
]);
|
||
},
|
||
|
||
down: async (queryInterface, Sequelize) => {
|
||
await queryInterface.bulkDelete('activities', null, {});
|
||
|
||
await queryInterface.bulkDelete('attachments', null, {});
|
||
|
||
await queryInterface.bulkDelete('clients', null, {});
|
||
|
||
await queryInterface.bulkDelete('deals', null, {});
|
||
|
||
await queryInterface.bulkDelete('leads', null, {});
|
||
|
||
await queryInterface.bulkDelete('notes', null, {});
|
||
|
||
await queryInterface.bulkDelete('organizations', null, {});
|
||
|
||
await queryInterface.bulkDelete('products', null, {});
|
||
|
||
await queryInterface.bulkDelete('organização', null, {});
|
||
},
|
||
};
|