如何在VS代码中将单行跨越成多行?
Posted
技术标签:
【中文标题】如何在VS代码中将单行跨越成多行?【英文标题】:How to span single line into multiple lines in VS code? 【发布时间】:2021-07-25 14:39:32 【问题描述】:我有以下用nodeJS编写的代码..
async function GetSellerInfoByID(seller_user_id)
console.debug("Method : GetSellerInfoByID @user.service.js Calling...");
await clientDB.connect();
dataBaseData = await clientDB.query('select seller_profiles.user_id,seller_profiles.business_name,seller_profiles.status, buyer_profiles.first_name, images.image_url buyer_profiles.last_name, user_details.email from seller_profiles inner join user_details on user_details.user_id = seller_profiles.user_id left join address_books on address_books.id = seller_profiles.address_book_id left join phone_numbers on phone_numbers.id = seller_profiles.phone_number_id inner join buyer_profiles on buyer_profiles.user_id = seller_profiles.user_id left join images on images.id = seller_profiles.business_logo_id where seller_profiles.user_id = $1', [seller_user_id,]);
//dataBaseData = await clientDB.query('select * from user_auth_validation where user_username=$1', [username]);
if(dataBaseData.rows.length > 0)
// dataBaseData.rows.forEach(element =>
console.debug("data have.");
//userID = element.user_id;
// );
// console.debug(dataBaseData.rows);
else
console.debug("Error in entered data, Please Check you Data Again.");
clientDB.end();
return dataBaseData;
如您所见,我的 SQL 查询总是希望在一行中。 我想显示如下:(为了可读性)
dataBaseData = await clientDB.query('select seller_profiles.user_id,seller_profiles.business_name,seller_profiles.status, buyer_profiles.first_name, images.image_url, buyer_profiles.last_name, user_details.email from seller_profiles
inner join user_details on user_details.user_id = seller_profiles.user_id left join address_books on address_books.id = seller_profiles.address_book_id
left join phone_numbers on phone_numbers.id = seller_profiles.phone_number_id
inner join buyer_profiles on buyer_profiles.user_id = seller_profiles.user_id
left join images on images.id = seller_profiles.business_logo_id
where seller_profiles.user_id = $1', [seller_user_id,]);
如何在 VS 代码中做到这一点?
【问题讨论】:
【参考方案1】:您可以使用代码格式化程序扩展 (prettier),它会在您保存文件时自动重新格式化您的代码并使其可读。
【讨论】:
【参考方案2】:我建议您将其拆分为子字符串,然后根据需要连接。
【讨论】:
不需要作为代码的一部分。以上是关于如何在VS代码中将单行跨越成多行?的主要内容,如果未能解决你的问题,请参考以下文章