Best thing to do in creating a auto increment id for the sub-item of a document

.net

#1

Hi,

What is the best way in dealing of adding an ids to the sub-item of a document. The structure is something like this:

“id” : “1”,
“name” : “test”,
"sub-item: [
{
“item” : “value”,
“item2” : “value2”
}
]

The concept is I should be able to delete the sub-item record by adding a boolean field as ‘delete’ and an ‘Id’ that will auto-increment based on how many records it has. It will look like, like this:

“id” : “1”,
“name” : “test”,
"sub-item: [
{
“id” : “idValue”,
“item” : “value”,
“item2” : “value2”,
“deleted” : false
}
]

Any advice will be appreciated. :smile:

Thanks!


#2

Hey @robert,

I’m not sure I understand.

So in the example you gave you’d expect the id value for sub-item to be 2? I am trying to figure out what your expected values are and your desired use case. I should be able to advise when I better understand what the goals are.

Best,


#3

Hi @nraboy

What I meant was I want to have the sub-items their own id and be able to exclude them when querying like: sub-item delete not equal to true.

Kindest Regards,
Robert