MVC :: What is a model?

前端 未结 5 1871
情深已故
情深已故 2021-02-05 04:07

I am at a point where I must make a decision about models. I am aware that models are what you use to do all your database manipulation. But are models restricted to this?

<
5条回答
  •  悲&欢浪女
    2021-02-05 04:08

    For example, in Django, model is a class that maps to the data relation (table) and potentially bridge tables (e.g. for many to many relations).

    The same class can have methods for the manipulations on the corresponding data, there could be additional classes that are not defining models by themselves, but the methods of accessing and filtering the data.

    But term model in MVC does apply to describing data structures and the methods to access them in general.

    The frameworks may be somewhat bending the abstract terminology. For example what Django calls views are actually controller functions, and the entities defining the presentation are called templates, instead of views.

提交回复
热议问题