A
A
Alecxandrys2016-05-03 22:31:31
MongoDB
Alecxandrys, 2016-05-03 22:31:31

How to change the value of an entry?

Good afternoon,
There is a collection
battles = new Mongo.Collection('battles');
It is filled with records of this type

var BS = new BattleState(path, 20, 12,prevuser.deck,user.deck);
                            battles.insert({
                                ID1     : prevuser.userId,
                                name1   : prevuser.username,
                                ID2     : user.userId,
                                name2   : user.username,
                                BS      : BS,
                                battleID: path
                            });

BattleState has the following constructor
BattleState = function(ID, sizeX, sizeY, deck1, deck2)
    {
        var mapHash = setMapHash(sizeX, sizeY);
        this.map = createMap(mapHash, sizeX, sizeY);//{}
        this.deck1 = deck1;//[]
        this.deck2 = deck2;//[]
    };

We need to add some fields (positionX and positionY) to the element (assume at index 0) of the deck1 array in the document BS object.
That is, if you take a single entry, then you need to change the values ​​in battle.BS.deck1.[0]
How to make a modifier?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Alecxandrys, 2016-05-05
@Alecxandrys

Solved the problem by editing the entire deck and overwriting it entirely

deck=battles.findOne({}).BS.deck1;
                    deck[card].column=column;
                    deck[card].row=row;
                    deck[card].placed=true;
                    battles.update(_id,{$set:{'BS.deck1':deck}});

S
soulness, 2016-06-20
@soulness

working with arrays in mongo is very easy, just specify the index.

var deck = {column: column,
                   row: row,
                   placed: true };
battles.update(_id, {$set: { 'BS.deck1.0': deck}});

E
Espleth, 2015-06-04
@Espleth

Your requirements are low. Here you drive in the characteristics of interest and look for a suitable option.
Apparently, almost any laptop will cope with your tasks.
I can only advise the possibility of expanding the RAM up to 16GB (it will not be superfluous), and an SSD (well, or a slot for it)

I
Ilya Pavlov, 2015-06-04
@PiCoderman

Acer aspire. Namely, which one do you choose?

N
Nikolai, 2015-06-04
@hellsq

unlike previous commentators, I would recommend not to buy laptops in our country, but to buy on the same computeruniverse.ru - it’s not always much cheaper there (laptops are usually cheaper by 5-10 thousand), but there is a much larger selection of different configurations. for example, Acer V3 on i5, with 8 gigs of RAM, SSD and 1080 screen in Moscow time. didn't exist when I was looking. and the same model with 6GB of memory cost about 50k, when in Germany it cost 30k.

B
bobrovskyserg, 2015-06-04
@bobrovskyserg

tyts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question