|
|
|
@ -22,6 +22,15 @@ var Note = sequelize.define('Note', { |
|
|
|
views: Sequelize.INTEGER, |
|
|
|
views: Sequelize.INTEGER, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Shortcut = sequelize.define('Shortcut', { |
|
|
|
|
|
|
|
id: { type: Sequelize.STRING, unique: true, primaryKey: true }, |
|
|
|
|
|
|
|
lastResolution: { type: Sequelize.DATE, allowNull: true, defaultValue: null }, |
|
|
|
|
|
|
|
params: Sequelize.STRING |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Note.hasMany(Shortcut);
|
|
|
|
|
|
|
|
Shortcut.belongsTo(Note); |
|
|
|
|
|
|
|
|
|
|
|
sequelize.sync().then(function () { |
|
|
|
sequelize.sync().then(function () { |
|
|
|
client.hgetall("note", function (err, notes) { |
|
|
|
client.hgetall("note", function (err, notes) { |
|
|
|
console.log("notes retrieved:", Object.keys(notes).length); |
|
|
|
console.log("notes retrieved:", Object.keys(notes).length); |
|
|
|
@ -35,8 +44,9 @@ sequelize.sync().then(function () { |
|
|
|
console.log("views retrieved:", Object.keys(views).length); |
|
|
|
console.log("views retrieved:", Object.keys(views).length); |
|
|
|
client.hgetall("edited", function (err, edited) { |
|
|
|
client.hgetall("edited", function (err, edited) { |
|
|
|
console.log("edited retrieved:", Object.keys(edited).length); |
|
|
|
console.log("edited retrieved:", Object.keys(edited).length); |
|
|
|
console.log("all infos retrieved"); |
|
|
|
|
|
|
|
Object.keys(notes).forEach(function (id) { |
|
|
|
Object.keys(notes).forEach(function (id) { |
|
|
|
|
|
|
|
client.smembers(id + ":urls", function (err, links) { |
|
|
|
|
|
|
|
|
|
|
|
Note.create({ |
|
|
|
Note.create({ |
|
|
|
id: id, |
|
|
|
id: id, |
|
|
|
text: notes[id], |
|
|
|
text: notes[id], |
|
|
|
@ -45,8 +55,33 @@ sequelize.sync().then(function () { |
|
|
|
password: password[id] && password[id].length == 32 && password[id], |
|
|
|
password: password[id] && password[id].length == 32 && password[id], |
|
|
|
edited: !isNaN(edited[id]) && edited[id] && new Date(edited[id] * 1000) || null, |
|
|
|
edited: !isNaN(edited[id]) && edited[id] && new Date(edited[id] * 1000) || null, |
|
|
|
views: views[id], |
|
|
|
views: views[id], |
|
|
|
|
|
|
|
}).then(note => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
links.forEach(shortcutId => { |
|
|
|
|
|
|
|
client.hget("short-url", shortcutId, function (err, result){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Shortcut.create({ |
|
|
|
|
|
|
|
id: shortcutId, |
|
|
|
|
|
|
|
params: result |
|
|
|
|
|
|
|
}).then(shortcut => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
debugger |
|
|
|
|
|
|
|
shortcut.setNote(note); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|