shortcuts imported; note import completed
This commit is contained in:
+18
-12
@@ -28,7 +28,7 @@ var Shortcut = sequelize.define('Shortcut', {
|
||||
params: Sequelize.STRING
|
||||
});
|
||||
|
||||
//Note.hasMany(Shortcut);
|
||||
Note.hasMany(Shortcut);
|
||||
Shortcut.belongsTo(Note);
|
||||
|
||||
sequelize.sync().then(function () {
|
||||
@@ -58,28 +58,34 @@ sequelize.sync().then(function () {
|
||||
}).then(note => {
|
||||
|
||||
links.forEach(shortcutId => {
|
||||
client.hget("short-url", shortcutId, function (err, result){
|
||||
client.hget("short-url", shortcutId, function (err, result) {
|
||||
|
||||
result = result.replace(/:([\w_-]+)\s/g, '"$1":');
|
||||
|
||||
var obj = {};
|
||||
try {
|
||||
obj = JSON.parse(result);
|
||||
delete obj.title;
|
||||
delete obj.day;
|
||||
delete obj.year;
|
||||
delete obj.month;
|
||||
|
||||
} catch (e) {
|
||||
return console.log("PARSE ERROR FOR", result)
|
||||
}
|
||||
|
||||
Shortcut.create({
|
||||
id: shortcutId,
|
||||
params: result
|
||||
params: Object.keys(obj).length == 0 ? null : JSON.stringify(obj)
|
||||
}).then(shortcut => {
|
||||
|
||||
debugger
|
||||
shortcut.setNote(note);
|
||||
note.addShortcut(shortcut);
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user