Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ZAD1
  2. db.studenci.insertOne({imie: "Pawel", nazwisko: "Stryjewski", wydzial: ObjectId('583ad919beeec1288f74d8bd')})
  3.  
  4. ZAD2
  5. function idWydzialu(sk) { var query = {}; query["skrot"] = sk; return db.wydzialy.findOne(query)._id;}
  6.  
  7. ZAD 3
  8. function dostepneKierunki() { print("LISTA WYDZIALOW"); db.wydzialy.find().forEach(function(x) { print(x.nazwa.toUpperCase() + ", " + x.kierunki.length + " kierunkow"); x.kierunki.forEach(function(y) {print("\t* " + y);}); }); }
  9.  
  10. ZAD4
  11. function dodajStudenta(imie, nazwisko, idWydzialu) { db.studenci.insertOne({"imie": imie, "nazwisko": nazwisko, "wydzial": idWydzialu}); }
  12.  
  13. ZAD5
  14. function listaStudentow() {
  15.   print("LISTA WSZYSTKICH STUDENTOW");
  16.   var studenci = db.studenci.find().toArray();
  17.   studenci.forEach(function(st) {
  18.     var query = {}; query["_id"] = st.wydzial;
  19.     st.wydzial = db.wydzialy.findOne(query).skrot;
  20.     print(st.imie + " " + st.nazwisko + " (" + st.wydzial + ")");
  21.   });
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement