1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/CliClient/app/command-dump.js

41 lines
847 B
JavaScript
Raw Normal View History

const { BaseCommand } = require('./base-command.js');
2017-12-14 20:12:14 +02:00
const Folder = require('lib/models/Folder.js');
const Note = require('lib/models/Note.js');
const Tag = require('lib/models/Tag.js');
2017-07-10 22:03:46 +02:00
class Command extends BaseCommand {
usage() {
return 'dump';
}
description() {
return 'Dumps the complete database as JSON.';
}
2017-07-18 20:21:03 +02:00
hidden() {
return true;
}
async action() {
2017-07-10 22:03:46 +02:00
let items = [];
const folders = await Folder.all();
2017-07-10 22:03:46 +02:00
for (let i = 0; i < folders.length; i++) {
const folder = folders[i];
const notes = await Note.previews(folder.id);
2017-07-10 22:03:46 +02:00
items.push(folder);
items = items.concat(notes);
}
const tags = await Tag.all();
2017-07-10 22:03:46 +02:00
for (let i = 0; i < tags.length; i++) {
2017-07-25 20:36:52 +02:00
tags[i].notes_ = await Tag.noteIds(tags[i].id);
2017-07-10 22:03:46 +02:00
}
items = items.concat(tags);
2017-10-07 18:30:27 +02:00
this.stdout(JSON.stringify(items));
2017-07-10 22:03:46 +02:00
}
}
module.exports = Command;