Javascript question

I can not understand why write a model? what is this for? I’m trying to make a project on YouTube from video clips, but I can’t figure it out.

You say your project is from video clips. My only guess is that this is from a tutorial that is leading up to using a database. That is what a model is more commonly associated with.

Do you have a link to the youtube video you took this from?

looks more like an attempt at a templating system which might possibly lead toward MVC, but… i cant… really fathom a why.

To me model in that script reads like a poorly chosen variable name. Something like data or blocks would fit better imo.

Isn’t that roughly what I was saying. The model in MVC being the section of code that handles a database. His example resembling a schema (of sorts)?

Either way it’s guessing without more info.

yes

I dont speak russian, but wow this feels overcomplicated for designing a single page node app.

1 Like

That is, for a beginner, this project will be difficult?

I don’t speak Russian, and it is not fair to judge this tutorial with just a quick scan through it. I’m sure it contains some good stuff to learn.

That said it does appear the tutor is writing a lot of the functionality from scratch. For instance I see this bit of code.

site.render(model)

model.forEach((block) => {
  site.insertAdjacentHTML(where: 'beforeend', block.toHTML())
})

The coding behind this looks like it is nicely done, and I am a fan of template literals, but I can’t help but think you should be using a framework like ejs or handlebars instead. Kind of re-inventing the wheel.

I see he has plenty of other tutorials though and some great topics, including nodejs + mongodb.

Maybe worth joining his discord, link is in the youtube description, and asking some questions there.

Just to familiarise yourself, here are a couple of links that introduce schemas.
https://mongoosejs.com/docs/guide.html

Personally I’d say go for it :slight_smile: