meteor - What is the difference of defining a global var in server/ and in private/? -


for example, want insert init json data db when meteor startup. , have 2 ways.

1. define in server/init.js

server/data.js: data1 = [{ "data": "to insert"}]; server/init.js meteor.startup(function() { inserttodb(data1); }); 

2. define in private/data.json

private/data.json [{ "data": "to insert"}]; server/init.js meteor.startup(function() {    var data2 =  assets.gettext("data.json");   inserttodb(data2);  }); 

a. data1 live time? if so, if data big, waste memory?

b. cons , pros?

c. general purpose or scenario of private?

it has little whether loading data file or defining statically , more data variable scope. if define globally yes, stored in memory lifetime of process. if define locally within function once function exits, memory freed.

for instance, can this:

server/init.js

meteor.startup(function() {    var data1 = [{ "data": "to insert"}];   inserttodb(data1); }); 

with said, here opinion if desire read it: logically, big block of data should not statically defined. save in separate file easy update. example of localization files.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -