[英]What is the cleanest way to save and load multiple DOM elements as JSON with the FileSystem(fs) Module from Node.js?
I need to save dynamically added DOM elements(draggable DIVs) to a file and load them at a later time. 我需要将动态添加的DOM元素(可拖动的DIV)保存到文件中,并在以后加载它们。 What is the cleanest way to accomplish this? 什么是最干净的方法来做到这一点?
You can save mySql or Mongodb 您可以保存mySql或Mongodb
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'locahost',
user : 'foo',
password : 'bar',
database : 'test'
});
// the callback inside connect is called when the connection is good
connection.connect(function(err){
var sql = "select 'Joe' as name from dual";
connection.query(sql, function(err, rows, fields) {
if (err) return console.log(err);
// you need to end your connection inside here.
connection.end();
console.log(rows[0].name);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.