-
Notifications
You must be signed in to change notification settings - Fork 0
/
cockdb.js
72 lines (68 loc) · 1.78 KB
/
cockdb.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const Sequelize = require("sequelize-cockroachdb");
// For secure connection:
const fs = require("fs");
const { username, password } = require("./config.json");
// Connect to CockroachDB through Sequelize.
var sequelize = new Sequelize({
dialect: "postgres",
username,
password,
host: "free-tier.gcp-us-central1.cockroachlabs.cloud",
database: "ragged-bison-977.bank",
port: 26257,
dialectOptions: {
ssl: {
// rejectUnauthorized: false,
// For secure connection:
ca: fs.readFileSync("./certs/cc-ca.crt").toString(),
},
},
logging: false,
});
// Define the Account model for the "accounts" table.
const Task = sequelize.define("tasks", {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
taskID: {
type: Sequelize.UUID,
},
assignor: {
type: Sequelize.STRING,
},
assignee: {
type: Sequelize.STRING,
},
task: {
type: Sequelize.STRING,
}
});
// Task.sync()
// .then(function () {
// // Insert two rows into the "accounts" table.
// return Task.bulkCreate([
// {
// taskID: "815654ce-7999-11eb-9439-0242ac130002",
// assignee: "598921289260073012",
// assignor: "598921289260073012",
// task:"blah23456789"
// }
// ]);
// })
// .then(function () {
// // Retrieve accounts.
// return Task.findAll();
// })
// .then(function (accounts) {
// // Print out the balances.
// accounts.forEach(function (account) {
// console.log(account.task + " " + account.assignee);
// });
// })
// .catch(function (err) {
// console.error("error: " + err.message);
// process.exit(1);
// });
module.exports = Task;