Skip to content

Commit

Permalink
sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
MelnCat committed Jun 28, 2023
1 parent 9f65729 commit c916d92
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 223 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
"dependencies": {
"@nuxt/kit": "^3.6.1",
"@vuestic/nuxt": "^1.0.14",
"pg": "^8.11.1",
"pg-hstore": "^2.3.4",
"sequelize": "^6.32.1"
"sequelize": "^6.32.1",
"sqlite3": "^5.1.6"
},
"packageManager": "[email protected]"
}
121 changes: 54 additions & 67 deletions server/db/sequelize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as pg from "pg";
import {
CreationOptional,
DataTypes,
Expand All @@ -10,11 +9,10 @@ import {
Sequelize,
} from "sequelize";

console.log(Object.keys(pg.default));
console.log(pg.default);
const sequelize = new Sequelize(process.env.POSTGRES_URL ? process.env.POSTGRES_URL + "?sslmode=require" : "postgres://vshacks2023:crabland2@localhost:5432/vshacks2023", {
const sequelize = new Sequelize({
dialect: "sqlite",
storage: "./.db/data.sqlite",
logging: false,
dialectModule: pg.default,
});
sequelize.authenticate();
export interface UserModel extends Model<InferAttributes<UserModel>, InferCreationAttributes<UserModel>> {
Expand All @@ -35,7 +33,7 @@ export const User = sequelize.define<UserModel>(
allowNull: false,
},
},
{ freezeTableName: true }
{}
);
export interface TeacherModel extends Model<InferAttributes<TeacherModel>, InferCreationAttributes<TeacherModel>> {
id: CreationOptional<number>;
Expand Down Expand Up @@ -65,7 +63,7 @@ export const Teacher = sequelize.define<TeacherModel>(
allowNull: false,
},
},
{ freezeTableName: true }
{}
);
export interface CourseModel extends Model<InferAttributes<CourseModel>, InferCreationAttributes<CourseModel>> {
id: string;
Expand All @@ -88,7 +86,7 @@ export const Course = sequelize.define<CourseModel>(
allowNull: false,
},
description: {
type: DataTypes.TEXT,
type: DataTypes.STRING,
allowNull: false,
},
image: {
Expand All @@ -101,7 +99,7 @@ export const Course = sequelize.define<CourseModel>(
type: DataTypes.INTEGER,
},
},
{ freezeTableName: true }
{}
);

Course.belongsTo(Teacher);
Expand All @@ -114,39 +112,35 @@ export interface UserCourseModel extends Model<InferAttributes<UserCourseModel>,
courseId: ForeignKey<string>;
}

export const UserCourse = sequelize.define<UserCourseModel>(
"usercourse",
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
},
semester: {
type: DataTypes.INTEGER,
allowNull: false,
},
block: {
type: DataTypes.INTEGER,
allowNull: false,
},
userId: {
type: DataTypes.INTEGER,
references: {
model: User,
key: "id",
},
export const UserCourse = sequelize.define<UserCourseModel>("usercourse", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
},
semester: {
type: DataTypes.INTEGER,
allowNull: false,
},
block: {
type: DataTypes.INTEGER,
allowNull: false,
},
userId: {
type: DataTypes.INTEGER,
references: {
model: User,
key: "id",
},
courseId: {
type: DataTypes.STRING,
references: {
model: Course,
key: "id",
},
},
courseId: {
type: DataTypes.STRING,
references: {
model: Course,
key: "id",
},
},
{ freezeTableName: true }
);
});

Course.hasMany(UserCourse);
UserCourse.belongsTo(Course);
Expand Down Expand Up @@ -189,7 +183,7 @@ export const Assignment = sequelize.define<AssignmentModel>(
type: DataTypes.INTEGER,
},
},
{ freezeTableName: true }
{}
);
Assignment.belongsTo(User);
Assignment.belongsTo(Course);
Expand Down Expand Up @@ -324,36 +318,32 @@ sequelize.sync({ force: true }).then(async x => {
name: "Composition 10",
room: 2033,
teacher: "Mr. Smith",
description:
"Composition 10 is designed to support students in their development of written communication through a critical process of questioning, exploring, and sampling. Within a supportive community of writers, students will work individually and collaboratively to explore and create coherent, purposeful compositions. Students will read and study compositions by other writers and consider a variety of styles as models for the development of their writing.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Austria_-_G%C3%B6ttweig_Abbey_-_2015.jpg/640px-Austria_-_G%C3%B6ttweig_Abbey_-_2015.jpg",
description: "Composition 10 is designed to support students in their development of written communication through a critical process of questioning, exploring, and sampling. Within a supportive community of writers, students will work individually and collaboratively to explore and create coherent, purposeful compositions. Students will read and study compositions by other writers and consider a variety of styles as models for the development of their writing.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Austria_-_G%C3%B6ttweig_Abbey_-_2015.jpg/640px-Austria_-_G%C3%B6ttweig_Abbey_-_2015.jpg"
},
{
id: "GEFA-7676",
name: "Precalculus 10",
room: 1144,
teacher: "Ms. Kinley",
description:
"Through ten distinct units, students explore principles of algebra, geometry, and trigonometry and reinforce skills introduced in prior grades.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/L%C3%BCbeck%2C_Wissenschaftspfad%2C_Abakus_--_2017_--_0372.jpg/640px-L%C3%BCbeck%2C_Wissenschaftspfad%2C_Abakus_--_2017_--_0372.jpg",
description: "Through ten distinct units, students explore principles of algebra, geometry, and trigonometry and reinforce skills introduced in prior grades.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/L%C3%BCbeck%2C_Wissenschaftspfad%2C_Abakus_--_2017_--_0372.jpg/640px-L%C3%BCbeck%2C_Wissenschaftspfad%2C_Abakus_--_2017_--_0372.jpg"
},
{
id: "FMNE-4443",
name: "CLE 10",
room: 3322,
teacher: "Ms. Roberts",
description:
"Today鈥檚 graduates must be able to adapt to ongoing change in many aspects of their lives. Purposeful career-life development, in which students learn how to set personally meaningful goals, recognize and cultivate relevant opportunities and supportive relationships, and continually re-evaluate and revise their plans, is a necessity for educated citizens in an ever-changing world.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/Architecture_Classroom_in_the_Carnegie_Mellon_College_of_Fine_Arts.jpg/640px-Architecture_Classroom_in_the_Carnegie_Mellon_College_of_Fine_Arts.jpg",
description: "Today鈥檚 graduates must be able to adapt to ongoing change in many aspects of their lives. Purposeful career-life development, in which students learn how to set personally meaningful goals, recognize and cultivate relevant opportunities and supportive relationships, and continually re-evaluate and revise their plans, is a necessity for educated citizens in an ever-changing world.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/Architecture_Classroom_in_the_Carnegie_Mellon_College_of_Fine_Arts.jpg/640px-Architecture_Classroom_in_the_Carnegie_Mellon_College_of_Fine_Arts.jpg"
},
{
id: "FAFJ-3423",
name: "Science 10",
room: 2123,
teacher: "Ms. Mann",
description:
"Science 10 is designed to support students in their development of scientific literacy. Students will study a variety of topics that address the big ideas of science. They will develop their scientific inquiry skills as they explore the relationships between science, technology, society, and the environment, and become aware of how science-related careers and research affect their lives.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Openluchtmuseum_Arnhem_-_Laboratorium_Zuivelfabriek_Freia.jpg/639px-Openluchtmuseum_Arnhem_-_Laboratorium_Zuivelfabriek_Freia.jpg",
description: "Science 10 is designed to support students in their development of scientific literacy. Students will study a variety of topics that address the big ideas of science. They will develop their scientific inquiry skills as they explore the relationships between science, technology, society, and the environment, and become aware of how science-related careers and research affect their lives.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Openluchtmuseum_Arnhem_-_Laboratorium_Zuivelfabriek_Freia.jpg/639px-Openluchtmuseum_Arnhem_-_Laboratorium_Zuivelfabriek_Freia.jpg"
},
].map(async (x, i) => {
const ph = Math.tan(x.teacher.charCodeAt(4)) + Math.tan(x.teacher.charCodeAt(5));
Expand All @@ -373,7 +363,7 @@ sequelize.sync({ force: true }).then(async x => {
room: x.room,
teacherId: teacher.id,
description: x.description,
image: x.image,
image: x.image
})
)[0];
})
Expand All @@ -385,7 +375,7 @@ sequelize.sync({ force: true }).then(async x => {
courseId: x.id,
userId: user.id,
semester: 1,
block: i + 1,
block: i + 1
});
})
);
Expand All @@ -396,28 +386,25 @@ sequelize.sync({ force: true }).then(async x => {
name: "Intermediate Band 10",
room: 3000,
teacher: "Mr. Wilson",
description:
"This course is designed to provide students with the opportunity to develop their musical skills through the study and performance of a variety of band music. Students will develop their technical skills, rhythmic skills, and musicality through the study of scales, technical exercises, and band repertoire. Students will also develop their ability to work collaboratively with others as they rehearse and perform with the band.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Israel_Philharmonic_Orchestra.jpg/640px-Israel_Philharmonic_Orchestra.jpg",
description: "This course is designed to provide students with the opportunity to develop their musical skills through the study and performance of a variety of band music. Students will develop their technical skills, rhythmic skills, and musicality through the study of scales, technical exercises, and band repertoire. Students will also develop their ability to work collaboratively with others as they rehearse and perform with the band.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Israel_Philharmonic_Orchestra.jpg/640px-Israel_Philharmonic_Orchestra.jpg"
},
{
id: "EKFE-7354",
name: "Woodworking 10",
room: 3322,
teacher: "Ms. Reid",
description:
"Woodworking 10 provides students with the opportunity to develop their woodworking skills through the study and construction of a variety of projects. Students will develop their technical skills, safety skills, and creativity through the study of woodworking techniques and the construction of projects. Students will also develop their ability to work collaboratively with others as they work in the shop.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Puy_du_Fou.-_La_Cit%C3%A9_M%C3%A9di%C3%A9vale_%281%29.JPG/640px-Puy_du_Fou.-_La_Cit%C3%A9_M%C3%A9di%C3%A9vale_%281%29.JPG",
description: "Woodworking 10 provides students with the opportunity to develop their woodworking skills through the study and construction of a variety of projects. Students will develop their technical skills, safety skills, and creativity through the study of woodworking techniques and the construction of projects. Students will also develop their ability to work collaboratively with others as they work in the shop.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Puy_du_Fou.-_La_Cit%C3%A9_M%C3%A9di%C3%A9vale_%281%29.JPG/640px-Puy_du_Fou.-_La_Cit%C3%A9_M%C3%A9di%C3%A9vale_%281%29.JPG"
},
{
id: "DFAA-6765",
name: "Computer Science 10",
room: 2003,
teacher: "Mr. Figgs",
description:
"Computer Science 10 is designed to provide students with the opportunity to develop their computational thinking skills through the study of computer science. Students will develop their ability to solve problems, design algorithms, write programs, and complete programming projects, using a variety of programming languages. Students will also develop their ability to work collaboratively with others as they develop and present their projects.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/CERN_Server_03.jpg/640px-CERN_Server_03.jpg",
},
description: "Computer Science 10 is designed to provide students with the opportunity to develop their computational thinking skills through the study of computer science. Students will develop their ability to solve problems, design algorithms, write programs, and complete programming projects, using a variety of programming languages. Students will also develop their ability to work collaboratively with others as they develop and present their projects.",
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/CERN_Server_03.jpg/640px-CERN_Server_03.jpg"
}
].map(async (x, i) => {
const ph = Math.tan(x.teacher.charCodeAt(4)) + Math.tan(x.teacher.charCodeAt(5));
const phone = ((ph < 100000000 ? ph * 100000000 : ph) % 10000000000).toString();
Expand All @@ -436,7 +423,7 @@ sequelize.sync({ force: true }).then(async x => {
room: x.room,
teacherId: teacher.id,
description: x.description,
image: x.image,
image: x.image
})
)[0];
})
Expand All @@ -448,8 +435,8 @@ sequelize.sync({ force: true }).then(async x => {
courseId: x.id,
userId: user.id,
semester: 2,
block: i === 2 ? 4 : i + 1,
block: i === 2 ? 4 : i + 1
});
})
);
});
});
Loading

0 comments on commit c916d92

Please sign in to comment.