-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathlevels.js
More file actions
40 lines (35 loc) · 1.1 KB
/
levels.js
File metadata and controls
40 lines (35 loc) · 1.1 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
/**
* levels belong to a single island, and have many slides. They don't have much metadata, as they are essentially
* just containers for slides. As mentioned in islands.js, the hierarchy used to be lessons/minilessons/slides
* so there is some lid/mlid/sid naming throughout these structures
*/
module.exports = function(sequelize, db) {
const l = sequelize.define("levels",
{
id: {
type: db.TEXT,
primaryKey: true
},
// level name
name: db.TEXT,
// level description (currently unused)
description: db.TEXT,
// 0-index
ordering: db.INTEGER,
// the ISLAND id this level belongs to
lid: db.TEXT,
// pt versions of above fields
pt_name: db.TEXT,
pt_description: db.TEXT
},
{
freezeTableName: true,
timestamps: false
}
);
l.associate = models => {
l.belongsTo(models.islands, {foreignKey: "lid", targetKey: "id", as: "island", foreignKeyConstraint: true});
l.hasMany(models.slides, {foreignKey: "mlid", sourceKey: "id", as: "slides", foreignKeyConstraint: true});
};
return l;
};