[英]What is the cleanest way to save and load multiple DOM elements as JSON with the FileSystem(fs) Module from Node.js?
我需要將動態添加的DOM元素(可拖動的DIV)保存到文件中,並在以后加載它們。 什么是最干凈的方法來做到這一點?
您可以保存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.