Files
AVEF/imports/startup/server/postStartup/version.js
Wynne Crisman 2593d0f977 Appreciation Editor Complete / All Others Incomplete
The text editor for the appreciation page is complete, but all other files are empty, besides User Manager.
2018-08-17 11:24:00 -07:00

35 lines
865 B
JavaScript

import SimpleSchema from 'simpl-schema';
let AppVersion = new Mongo.Collection('AppVersion');
let AppVersionSchema = new SimpleSchema({
version: {
type: Number,
optional: false,
defaultValue: 0
}
});
AppVersion.attachSchema(AppVersionSchema);
try {
let appVersions = AppVersion.find({}).fetch();
let appVersion;
if(!appVersions || appVersions.length == 0) { //This will happen only when first creating a database.
appVersion = {version: 0};
appVersion._id = AppVersion.insert(appVersion);
}
else if(appVersions.length > 1) { //This should never happen. Remove all but the first app version.
for(let i = 1; i < appVersions.length; i++) {
AppVersion.remove(appVersions[i]._id);
}
}
else {
appVersion = appVersions[0];
}
}
catch(err) {
console.log("Caught an error while upgrading the app version: " + err);
process.exit(1);
}