From 884486329cd466c85b5eb043ee4cd6ccdf01f4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Sun, 13 Sep 2015 13:20:43 +0200 Subject: [PATCH] storage debug conf added --- .vscode/launch.json | 42 ++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +++- src/storage.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 src/storage.js diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..c71297c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,42 @@ +{ + "version": "0.1.0", + // List of configurations. Add new configurations or edit existing ones. + // ONLY "node" and "mono" are supported, change "type" to switch. + "configurations": [ + { + // Name of configuration; appears in the launch configuration drop down menu. + "name": "Launch storage.js", + // Type of configuration. Possible values: "node", "mono". + "type": "node", + // Workspace relative or absolute path to the program. + "program": "bin/storage.js", + // Automatically stop program after launch. + "stopOnEntry": false, + // Command line arguments passed to the program. + "args": [], + // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. + "cwd": ".", + // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. + "runtimeExecutable": null, + // Optional arguments passed to the runtime executable. + "runtimeArgs": ["--nolazy"], + // Environment variables passed to the program. + "env": { + "NODE_ENV": "development" + }, + // Use JavaScript source maps (if they exist). + "sourceMaps": false, + // If JavaScript source maps are enabled, the generated code is expected in this directory. + "outDir": null + }, + { + "name": "Attach", + "type": "node", + // TCP/IP address. Default is "localhost". + "address": "localhost", + // Port to attach to. + "port": 5858, + "sourceMaps": false + } + ] +} diff --git a/package.json b/package.json index 865a68b..07d3198 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ "dependencies": { "express": "^4.13.3", "lru-cache": "^2.6.5", - "marked": "^0.3.5" + "marked": "^0.3.5", + "sequelize": "^3.8.0", + "sqlite3": "^3.1.0" } } diff --git a/src/storage.js b/src/storage.js new file mode 100644 index 0000000..7032bab --- /dev/null +++ b/src/storage.js @@ -0,0 +1,44 @@ +var redis = require("redis"), + client = redis.createClient({ + return_buffers: true, + detect_buffers: false + }); + +var zlib = require('zlib'); + +var Sequelize = require('sequelize'); +var sequelize = new Sequelize('database', null, null, { + dialect: 'sqlite', + pool: { + max: 5, + min: 0, + idle: 10000 + }, + storage: 'database.sqlite' +}); + +client.hget("note", "2015/7/12/hom", function (err, B) { + debugger + console.log("to unpack:", B.toString("base64")); + var R = zlib.gunzipSync(B); + console.log(R); +}); + +/* +var User = sequelize.define('User', { + username: Sequelize.STRING, + birthday: Sequelize.DATE +}); + +sequelize.sync().then(function() { + return User.create({ + username: 'janedoe', + birthday: new Date(1980, 6, 20) + }); +}).then(function(jane) { + console.log(jane.get({ + plain: true + })) +}); + +*/ \ No newline at end of file