Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Model Store conflict

$
0
0
I'm gonna make an example of a problem that I'm having.
We're building an e-shop. In this e-shop you got a shopping-cart (cartModel), categories (categoryModel) and item-list (itemModel).

It looks like this:
  1. categoryModel & itemModel:
     - outdoor (id, name)
          - jacket (id, name, price)
  2.       - boots  (id, name, price)
  3.       - ...
     - indoor (id, name)
  4.       - blanket  (id, name, price)
  5.       - tv  (id, name, price)
  6.       - ...
  7.  - snow  (id, name)
  8.       - hat  (id, name, price)
  9.       - ... 
    - ...
Then you have the cartModel. (this has some saved previous selections:
  1. cartModel:
  2.      John: (id, name, ...)
  3.             - outdoor:
  4.                   - jacket

All of this model is rendered with ejs.

In this form-topic I've read that the categoryModel-instance is put in a store.

And here comes my problem. If  my cartModel is filled. It has an instance of the categoryModel. This categoryModel-instance is put into the model Store.

If I then load this same category. (in this example outdoor) Then it will fill the categoryInstance in my CartModel with all the items.

Then it looks like John has bought all the outdoor items.

How can I avoid this.  I want to keep those two categoryModel-instances with the same ID separated.

I hope this is clear. Else ask for more information?

Thnx!

- itemModel


Viewing all articles
Browse latest Browse all 3491

Trending Articles