D
D
dfhkjhg2020-08-29 11:36:56
JavaScript
dfhkjhg, 2020-08-29 11:36:56

How to assign an incremental id for each new item?

Suppose
there is a store
When a person buys an item in it, an item is added to his inventory:
(only these items are dynamic, they will often be removed from the inventory or new ones will be added)

{
 id: 1//и тут должен быть auto-increment
 itemid: 251//id именно предмета
 added_at: Date.now()
}


This is what the user looks like:
{
 id: 21, //тут тоже auto-increment но с ним проблем нет
 balance: 0,
 name: 'kek', 
 avatar: 'avatar'
 items: []// и тут хранятся предметы которые пользователь покупает. И как то для них надо сделать auto-increment и я не знаю как
}


is it possible to do this somehow normally or will I have to create a separate table where all items will be stored or a table in which there will simply be lastid?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Karpion, 2020-08-29
@Karpion

I think I answered this question yesterday.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question