forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-organization.js
More file actions
57 lines (52 loc) · 1.17 KB
/
create-organization.js
File metadata and controls
57 lines (52 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const createOrganization = async ({ slugify, data, key, trx, query }) => {
console.info(`\tCreating domain: ${data[key].acronym_en}.`)
const orgStruct = {
verified: true,
summaries: {
web: {
pass: 0,
fail: 0,
total: 0,
},
mail: {
pass: 0,
fail: 0,
total: 0,
},
},
orgDetails: {
en: {
slug: slugify(data[key].organization_en),
acronym: data[key].acronym_en,
name: data[key].organization_en,
zone: 'FED',
sector: 'TBS',
country: 'Canada',
province: 'Ontario',
city: 'Ottawa',
},
fr: {
slug: slugify(data[key].organization_fr),
acronym: data[key].acronym_fr,
name: data[key].organization_fr,
zone: 'FED',
sector: 'TBS',
country: 'Canada',
province: 'Ontario',
city: 'Ottawa',
},
},
}
const orgCursor = await trx.step(
() => query`
WITH organizations, domains, claims
INSERT ${orgStruct} INTO organizations
RETURN NEW
`,
)
const org = await orgCursor.next()
return org
}
module.exports = {
createOrganization,
}