Update database specifications and storage in the object

This commit is contained in:
chylex 2016-10-23 19:35:45 +02:00
parent 2ee1f6550b
commit 8112e5eda4

View File

@ -16,7 +16,7 @@
* <discord user id>, ... * <discord user id>, ...
* ], * ],
* *
* server: [ * servers: [
* { * {
* name: <server name>, * name: <server name>,
* type: <"SERVER"|"DM"> * type: <"SERVER"|"DM">
@ -25,7 +25,7 @@
* *
* channels: { * channels: {
* <discord channel id>: { * <discord channel id>: {
* server: <server index in the metadata.server array>, * server: <server index in the meta.servers array>,
* name: <channel name> * name: <channel name>
* }, ... * }, ...
* } * }
@ -53,14 +53,35 @@
* }, ... * }, ...
* } * }
* } * }
*
*
* TEMPORARY OBJECT STRUCTURE
* ==========================
*
* {
* userlookup: {
* <discord user id>: <user index in the meta.userindex array>
* }
* }
*/ */
var SAVEFILE = function(){ var SAVEFILE = function(){
this.db = {}; this.meta = {};
this.db.meta = {}; this.meta.users = {};
this.db.data = {}; this.meta.userindex = [];
this.meta.servers = [];
this.meta.channels = {};
this.data = {};
this.tmp = {};
this.tmp.userlookup = {};
};
}; };
SAVEFILE.prototype.toJson = function(){ SAVEFILE.prototype.toJson = function(){
return JSON.stringify(this.db); return JSON.stringify({
meta: this.meta,
data: this.data
});
}; };