mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-11-01 12:07:15 +08:00
ES2015 for assert and persistence utilities
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
this.assert = function(condition, message) {
|
||||
this.assert = (condition, message) => {
|
||||
if (!condition) {
|
||||
console.error(message);
|
||||
throw new Error;
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var child_process = Npm.require('child_process');
|
||||
var path = Npm.require('path');
|
||||
|
||||
function get_backup_path() {
|
||||
return path.join(process.env.PWD, 'server', 'backup');
|
||||
}
|
||||
|
||||
Meteor.methods({
|
||||
backup: function() {
|
||||
var path = get_backup_path();
|
||||
child_process.spawn('mongodump', ['--port', '3001', '--out', path]);
|
||||
},
|
||||
restore: function() {
|
||||
var path = get_backup_path();
|
||||
child_process.spawn('mongorestore', ['--port', '3001', '--drop', path]);
|
||||
},
|
||||
wipe: function() {
|
||||
base.collection.remove({});
|
||||
},
|
||||
});
|
||||
17
server/persistence.js
Normal file
17
server/persistence.js
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
const child_process = Npm.require('child_process');
|
||||
const path = Npm.require('path');
|
||||
|
||||
const get_backup_path = () => path.join(process.env.PWD, 'server', 'backup');
|
||||
|
||||
Meteor.methods({
|
||||
backup() {
|
||||
const path = get_backup_path();
|
||||
child_process.spawn('mongodump', ['--port', '3001', '--out', path]);
|
||||
},
|
||||
restore() {
|
||||
const path = get_backup_path();
|
||||
child_process.spawn('mongorestore', ['--port', '3001', '--drop', path]);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user