You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.
My app.js script always fails on the first run, when having a fresh rethink database. If I run my script once, then shut it down, then reload, everything seems to run just fine.
const Enmap = require('enmap');
const EnmapRethink = require('enmap-rethink');
var playerDB = [];
const playerAPI = new EnmapRethink({
name: 'players',
dbName: 'PLAYERSDB',
});
playerDB[0] = new Enmap({provider: playerAPI, persistent: true});
Even though i read from a get within the bot.on to decide if it exists or not, the error only calls up in the function (the line with set, any set in that function). I've tried making the function sync & async, passing playerDB in the call, using try/catch; Nothing changes, but it's only on the first time. If I restart the script after it's ran once with the rethink server up, it loads fine. I'm just not sure how to fix it?
It's hard to reproduce errors (still learning): I change something about the DB, I delete the rethink server data folder (remove clutter from the changed DB setup), run the rethink server, load the script and let it error, shut down the script, reload the script -- then no 'Insert' issue.
Also the reason I'm posting this issue here, I'm not sure how widely used Enmap-Rethink is, I assumed this would be the fastest way to get some help. I've attached app.js to this issue (in issue_file.zip), so the full scope is there. There is no sensitive code information.
The text was updated successfully, but these errors were encountered:
I... I don't understand at all what you're trying to do. Why would you possibly need to create an array of playerDB with one new enmap for each new player.. That makes no sense to me.
Did you maybe not realize that you could just... add objects to an enmap?
So instead of that weird code you have that pushes new enmaps into an array of enmaps, you could just... playerDB.set(M.user.id, {id: M.user.id, name: M.user.username, hexacoin: 10, exp: 0, level: 1});
I just feel your methodology is horribly backwards.
Actually this is the sort of code that the more I look at, the more I need eye bleach because there is so much horrendous errors in there it's a wonder it even runs at all under any circumstances. Trash all this, start from scratch, this is garbage.
I was under the impression that this only works with key:pair lists, I couldn't save objects or JSON files to the database. Kept telling me values must be strings or numbers. So I just opted into making an array for the players, and worked nicely with indexing. It's all backwards because that's how I've been learning, very slowly. Thanks for the kind words.
My app.js script always fails on the first run, when having a fresh rethink database. If I run my script once, then shut it down, then reload, everything seems to run just fine.
Then >
Even though i read from a get within the bot.on to decide if it exists or not, the error only calls up in the function (the line with set, any set in that function). I've tried making the function sync & async, passing playerDB in the call, using try/catch; Nothing changes, but it's only on the first time. If I restart the script after it's ran once with the rethink server up, it loads fine. I'm just not sure how to fix it?
It's hard to reproduce errors (still learning): I change something about the DB, I delete the rethink server data folder (remove clutter from the changed DB setup), run the rethink server, load the script and let it error, shut down the script, reload the script -- then no 'Insert' issue.
Also the reason I'm posting this issue here, I'm not sure how widely used Enmap-Rethink is, I assumed this would be the fastest way to get some help. I've attached app.js to this issue (in issue_file.zip), so the full scope is there. There is no sensitive code information.
The text was updated successfully, but these errors were encountered: