sql - Where is the right place for beautifying values from the DB for the user view? -
what mean question :
lets have web app (spring, angularjs, oracle/mysql). select db 2 columns represant interval example : "age_from" , "age_to". purpose display thouse 2 values lets "18" , "21" in client view "18 - 21".
so there many ways wonder between thouse two:
- select them db :
"select (age_from|| ' - ' || age_to) age_interval, ..."
, store string value backend object attribute :string ageinterval;
, after pass object(which contains field) client side can use "ageinterval" display interval client. i can select 2 columns db , store values different fields object :
double agefrom; double ageto;
(i store double values in case 1 also) , after pass object client side there can use js logic create string " agefrom - ageto " or directly display them html :<div> {{myobject.agefrom}} - {{myobject.ageto}} </div>
.
so main question shoud logic creating beautify view (string in our case: "18 - 21") displayed user (in html). server or client side or db select ?
you have key word in question title should decide: "beautifying". when see that, think "presentation layer". leave data access layer best: deal raw data. format data display in presentation layer. thus, prefer #2 on #1.
Comments
Post a Comment