-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatabaseSchema.js
44 lines (39 loc) · 1.01 KB
/
DatabaseSchema.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
/**
* The schema for a database using LocalDatabase.
*/
class DatabaseSchema {
/**
* The name of your database.
* @type {String}
*/
name = "";
/**
* The tables of your database.
* @type {Array.<TableSchema>}
*/
tables = [];
/**
* The names of all the tables in this database paired with the table schemas.
* @type {Object.<TableSchema>}
*/
tableMap = {};
/**
* The names of all the tables in this database.
* @type {Array.<String>}
*/
tableNames = [];
/**
* Generates a database blueprint for use in LocalDatabase.
* @param {String} name
* @param {Array.<TableSchema>} [tables] An array of the tables you want to have in this database.
*/
constructor(name, tables = []) {
this.name = name;
this.tables = tables;
tables.map(table => {
this.tableMap[table.name] = table;
this.tableNames.push(table.name);
});
}
}
export default DatabaseSchema;