Zum Inhalt

M165 NoSQL Datenbanken | Block 04

Inhaltsverzeichnis

Json-Aufgabe

JSON-Aufgabe MongoDB

Kein Json:

Movie Id = 14253
Movie Title = Beauty and the Beast
Release Year = 2016
Language = English
IMDb Rating = 6.4
Genre = Romance
Director = Christophe Gans
Runtime = 112

Json Dokument erstellen

{
  "_id": 14253,
  "title": "Beauty and the Beast",
  "releaseYear": 2016,
  "language": "English",
  "imdbRating": 6.4,
  "genre": "Romance",
  "director": "Christophe Gans",
  "runtime": 112
}
  • _id: eindeutige ID des Films in der Collection

  • title: Filmtitel

  • releaseYear: Erscheinungsjahr

  • language: Sprache

  • imdbRating: IMDb-Bewertung als Zahl

  • genre: Filmgenre

  • director: Regisseur

  • runtime: Laufzeit in Minuten

Json validiert

Einfügen in MongoDB

use moviesDB;

db.movies.insertOne({
  "_id": 14253,
  "title": "Beauty and the Beast",
  "releaseYear": 2016,
  "language": "English",
  "imdbRating": 6.4,
  "genre": "Romance",
  "director": "Christophe Gans",
  "runtime": 112
});

db.movies.find({ "_id": 14253 }).pretty();
Output