I'm going to kill myself.
In the nodejs server for my game, there's a function that pushes to an array.
It only works if the array is empty, no matter what type it is.
List of people that know why
- none

  • 0
    I'm intrigued. Can you link to a snippet?
  • 0
    We figured something out
    It's not the first one, its the second one that gets inputed into the array that shows up in the array.

    itemfunctions.addItem = function(itemname, username) {
    User.findOne({username: username}, (err, user) => {
    var users = user;
    var item = itemfunctions.itemInvTemplate;
    var iteminfo = itemfunctions.getItem(itemname);
    item.name = itemname;
    item.durabilty = iteminfo.durability;
    User.findOneAndUpdate({username: username}, users, {upsert:true}, function(err, doc){

    here's where the array is delcared
    inventory: [{name: String, durability: Number, metadata: [String]}]
  • 1
    Fixed it, just used mongodb push instead of js push
  • 3
    syntax error, I believe you mean:

    people_who_know_why = []
  • 2
    On the plus side, at least you'll be able to push yourself once you understand, then fix it and add others as you tell them how absurd this bug was
Add Comment