Node js SQL外部化?

工程机械

节点中是否有用于SQL外部化的工具?

我曾想过创建一个JSON文件来存储SQL语句,但我认为这不是最好的方法。

编辑:

例如,在Java中,您可以创建一个.properties文件,并为每个语句指定一个关键字。然后,将此文件导入到一个类中,并通过其关键字访问每个语句。我正在寻找类似的Java语言。

编辑2:

例子

sql.properties:

insertProduct = INSERT INTO products VALUES (?, ?, ?, ?)

我的课:

public class Example {

private Properties sqlProperties = // load file according to its location

//sqlProperties.getProperty('insertProduct'); will return the SQL from the sql.properties file

}

谢谢

皮特·达利多(Piotr Dajlido)

尝试使用npm packages它们是您Node.js解决方案的有用来源或扩展

对于解析.propertiesJAVA文件,您可能会感兴趣:

然后,您可以使用以下命令处理SQL调用:

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章