You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Shenouda Bertel <sh...@gmail.com> on 2010/12/27 12:04:54 UTC

CouchDB Carts and Orders Best Practice

Dears CouchDB Users,

    kindly, this tis my first official share after subscribe to CouchDB
Mailing List.

    I Would Like to ask for the Best Practice to Implement Shopping Carts in
CouchDB,
    in my application i can the Cart Model (Items).

    in the upcoming scenarios, any added item will be added to the document
and save the document which is a huge behavior and may have inconsistent
items.

    - As an array property of items in Order Document, which will carry the
items added to this Order
      which will create lots of orders that is not purchased, and didn't
have accurate numbers of Completed Orders.

    - As an array property of items in User Document, which will have that
added items to that User.
      in my case, the user will have a limited numbers of items, for example
in Conference Registration the user will buy only one Pass and one
reservation for Hotel if he likes.
      also in this case i will have multiple time of User Document Save in
every time Item added or changed.

    - As a separate Document for Cart which will have the items added to
this card and belongs to a user.

    - to add the cart items in memory and when checkout and creating an
order, will going to add the items in the memory to the items property in
the order Document.

   What is the best practice for the carts implementation with CouchDB,
which save the performance of the application, with less requests to CouchDB
and without several saving of the CouchDB Document.

Thanks,
Shenouda Bertel

Re: CouchDB Carts and Orders Best Practice

Posted by Dirkjan Ochtman <di...@ochtman.nl>.
On Mon, Dec 27, 2010 at 12:04, Shenouda Bertel <sh...@gmail.com> wrote:
>   What is the best practice for the carts implementation with CouchDB,
> which save the performance of the application, with less requests to CouchDB
> and without several saving of the CouchDB Document.

I would have a separate document per cart item (i.e. the item has two
"foreign keys", pointers to both the user and the product), so you can
update each item separately and can use a view to easily retrieve all
of the items in the cart, and lets you update the document for each
item separately.

Cheers,

Dirkjan