-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodelsTest.js
42 lines (35 loc) · 1.05 KB
/
modelsTest.js
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
const db = require("./models")
const chalk = require("chalk")
const createTag = async () => {
try {
const timer = await db.Timer.findByPk(3)
timer.createTag({ name: "New", color: "yellow", UserId: 1 })
} catch (error) {
console.error(chalk.red("Error creating tag"), chalk.red(error))
}
}
const props = async () => {
const tag = await db.Tag.findByPk(1, { include: db.Timer })
console.log(chalk.yellow(Object.keys(tag)))
const timers = tag.Timers
timers.forEach((timer) => console.log(chalk.green(timer.name)))
// console.log(chalk.green(tag.Timers))
}
const createTimerSection = async () => {
const timer = await db.Timer.findOne()
if (timer) console.log(chalk.green("Found a timer"))
await timer.createTimerSection({
name: "Section 2",
duration: "20",
color: "red",
})
}
const findTimerSections = async () => {
const timer = await db.Timer.findByPk(3, { include: db.TimerSection })
const sections = timer.TimerSections
console.log(sections)
}
// createTag()
// props()
// createTimerSection()
findTimerSections()