How to create a model for example Book without connecting a database? All the guides use the database, I just need to make a model check how the request goes and return json. An alternative to a database is an object or an array.

  • Your question is not quite clear, do you want to check how the database query goes without creating a database? Or do you want the server to lay a json-file and you give it when you request it? - greybutton
  • And what exactly do you understand by model? - Dmitriy Simushev
  • I already understood that at the time of writing the question I essentially did not understand what I was asking. I get a little bit into the js stupor after java where everything is obvious to me, there are models, controllers, interfaces, services. And then how it came to mind. My question is no longer relevant array or object is created as usual. - Sergei R

1 answer 1

If you just need a large array for some tests, you can download, for example, on the https://github.com/dwyl/english-words file words.txt

var DATA = fs.readFileSync("./words.txt", "utf8").split("\n"); 

and there will be an array of 270+ thousand words. If you need JSON, you can also find a big JSON and load it in a similar way.

  var JSON = JSON.parse(fs.readFileSync("./filename.json"));