M
M
MrZillaGold2019-10-25 13:00:07
JavaScript
MrZillaGold, 2019-10-25 13:00:07

How to use variable as table column name?

The request looks like this

profileModel.findOneAndUpdate({_id: parseInt(user_id)}, {owner: badgeValue})
                            .then(() => {
                                done();
                            });

I would like to use a variable as a column name in a table, for example:
const name = "owner"
profileModel.findOneAndUpdate({_id: parseInt(user_id)}, {name || `${name}`: badgeValue})
                            .then(() => {
                                done();
                            });

But such requests do not go through, is there a correct solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artur Karapetyan, 2019-10-25
@MrZillaGold

5db2cda5b4bca214708430.png
or poke

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question