PostgreSQL 购物车
All functionality is in PostgreSQL’s PL/pgSQL functions.
| SELECT * FROM … | result |
|---|---|
| items_get() | show all items |
| cart_get(person_id) | get cart (unpaid invoice) |
| lineitem_add(person_id, item_id, quantity) | add item to cart |
| lineitem_delete(lineitems.id) | delete lineitem in cart |
| lineitem_update(lineitems.id, quantity) | change quantity (0=delete) |
| invoice_get(invoices.id) | get order |
| invoice_update(invoices.id, country) | update country |
| invoice_update(invoices.id, country, address) | update address |
| invoice_delete(invoices.id) | delete order |
| invoice_paid(invoices.id, payment info) | mark order as paid |
| invoices_get() | show all orders |
| invoices_get_unshipped() | orders needing to be shipped |
| invoice_shipped(invoice_id, info) | mark order as shipped |
| invoices_get_for(person_id) | this person’s orders |
| items_get_for(person_id) | items this person has paid for |
gem install pg
gem install json
sh init.sh
sh reset.sh
ruby test-db.rb
ruby test-api.rb…All functions, views, and triggers are in the "store" schema.
So any time you make a change, you can run … "drop schema store cascade; create schema store" … then re-load them all anytime. It won't lose your data.
Email me at
Sorry I won’t be watching pull-requests or issues here. I’m posting this just as some example code.
暂无开放 Issues,或尚未同步最近议题。