mapping out db relations to js object - recursive object refs issue

Viewed 12

So, my use case is this. I'm trying to map out a simple db structure to js objects like so:

Lets say I have the following db structure: User -> Order -> Order Item -> Product Category

But in the Order there is a "Created By" which links to -> User, and there is also a "Created By" in the "Product Category".

Now I have a list of JS Objects that I need to have a js object representing each of the entities so something like so:

User: {...userProps}, 
Order: {...orderProps, createdBy: '#UserObj -> Ref'}, 
Order Item: {...orderItemProps, productCategory: '#ProductCategoryObj -> Ref''},
ProductCategory: {...productCategoryProps, createdBy: '#UserObj -> Ref''}

Very clearly there is a recursive dependency. So how best to deal with this?

0 Answers
Related