File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 11import express from "express" ;
22import cors from "cors" ;
33import mongoose from "mongoose" ;
4- import netflixData from "./data/netflix-titles.json" assert { type : "json " } ;
4+ import fs from "fs" ;
5+
6+ const rawData = fs . readFileSync ( "./data/netflix-titles.json" ) ;
7+ const netflixData = JSON . parse ( rawData ) ;
58
69const mongoUrl = process . env . MONGO_URL || "mongodb://localhost/netflix_titles" ;
710mongoose . connect ( mongoUrl , { useNewUrlParser : true , useUnifiedTopology : true } ) ;
@@ -14,15 +17,14 @@ const app = express();
1417app . use ( cors ( ) ) ;
1518app . use ( express . json ( ) ) ;
1619
17- // Define the model
1820const NetflixTitle = mongoose . model ( "NetflixTitle" , {
1921 show_id : Number ,
2022 title : String ,
2123 country : String ,
2224 release_year : Number ,
2325 rating : String ,
2426 description : String ,
25- } ) ;
27+ } , "netflixtitles" ) ; // Namnet på kollektionen i MongoDB
2628
2729// Seed the database
2830if ( process . env . RESET_DB ) {
You can’t perform that action at this time.
0 commit comments