6. Datenstrukturen - TugceAtay/GDW_Ay_Koese_Atay GitHub Wiki

Schema: fach.js
const mongoose = require(‘mongoose’);

const fachSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
fachname: {type: String, required: true},
lernstoffid: {type: mongoose.Schema.Types.ObjectId, ref: ‘Lernstoff’, required: true},
lehrerid: {type: mongoose.Schema.Types.ObjectId, ref: ‘Lehrer’, required: true},
schuelerid: {type: mongoose.Schema.Types.ObjectId, ref: ‘Schueler’, required: true},
klassenid: {type: mongoose.Schema.Types.ObjectId, ref: ‘Klassen’, required: true}
});
module.exports = mongoose.model(‘Fach’, fachSchema);

Schema: klassen.js
const mongoose = require(‘mongoose’);

const klassenSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
bezeichnung: {type: String, required: true},
jahrgang: {type: String, required: true},
lehrerid: {type: mongoose.Schema.Types.ObjectId, ref: ’Lehrer’},
schuelerid: {type: mongoose.Schema.Types.ObjectId, ref: ’Schueler’},
});
module.exports = mongoose.model(‘Klassen’, klassenSchema);

Schema: lernstoff.js
const mongoose = require(‘mongoose’);

const lernstoffSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
fachid: {type: mongoose.Schema.Types.ObjectId, ref: ’Fach’},
klassenid: {type: mongoose.Schema.Types.ObjectId, ref: ’Klassen’}
});
module.exports = mongoose.model(‘Lernstoff’, lernstoffSchema);

const mongoose = require(‘mongoose’);

Schema: lehrer.js
const lehrerSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
vorname: {type: String, required: true},
nachname: {type: String, required: true},
plz: {type: Number, required: true},
fachid: {type: mongoose.Schema.Types.ObjectId, ref: ’Fach’},
schuelerid: {type: mongoose.Schema.Types.ObjectId, ref: ’Schueler’},
klassenid: {type: mongoose.Schema.Types.ObjectId, ref: ’Klassen’}
});
module.exports = mongoose.model(‘Lehrer’, lehrerSchema);

Schema: schueler.js
const mongoose = require(‘mongoose’);

const schuelerSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
vorname: {type: String, required: true},
nachname: {type: String, required: true},
plz: {type: Number, required: true},
fachid: {type: mongoose.Schema.Types.ObjectId, ref: ’Fach’},
lehrerid: {type: mongoose.Schema.Types.ObjectId, ref: ’Lehrer’},
klassenid: {type: mongoose.Schema.Types.ObjectId, ref: ’Klassen’}
});
module.exports = mongoose.model(‘schueler’, schuelerSchema);

Schema: schule.js
const mongoose = require(‘mongoose’);

const schuleSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
schulname: {type: String, required: true},
adresse: {type: String, required: true},
lehrerid: {type: mongoose.Schema.Types.ObjectId, ref: ’Lehrer’},
schuelerid: {type: mongoose.Schema.Types.ObjectId, ref: ’Schueler’},
klassenid: {type: mongoose.Schema.Types.ObjectId, ref: ’Klassen’}
});
module.exports = mongoose.model(‘Schule’, schuleSchema);

⚠️ **GitHub.com Fallback** ⚠️