options.filename = dbPath+'picker';
pickerDB = new Datastore(options);
options.filename = dbPath+'data';
dataDB = new Datastore(options);
options.filename = dbPath+'web';
webDB = new Datastore(options);
options.filename = dbPath+'url';
urlDB = new Datastore(options);
options.filename = dbPath+'attach';
attachDB = new Datastore(options);
options.filename = dbPath+'cacheUrl';
cacheUrlDB = new Datastore(options);
options.filename = dbPath+'cache';
cacheDB = new Datastore(options);
options.filename = dbPath+'cron';
cronDB = new Datastore(options);
options.filename = dbPath+'log';
logDB = new Datastore(options);
options.filename = dbPath+'cronLog';
cronLogDB = new Datastore(options);
请教一下,这一大段,都是复制粘贴。能用更简洁的代码一次搞定吗?
不知道算不算你心中的簡寫,我覺得從重複的角度看,把不同的部分提取出來做個數組,把相同的部分抽象,如下:
不知道你接下來的程式碼怎麼用?如果後邊的邏輯程式碼好改,可以改成: