7

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

Comments
  • 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.

    @ihatecomputers
    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;
    users.inventory.push(item);
    User.findOneAndUpdate({username: username}, users, {upsert:true}, function(err, doc){
    console.log(err);
    console.log("a");
    return;
    });
    });
    }

    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