dchester/epilogue

How to post a mutli-tiered json object?

mgudesblatart opened this issue · 2 comments

I need to post this object below

`{
"customer": {
"name": "string",
"phone": "string",
"address1": "string",
"address2": "string",
"city": "string",
"state": "string",
"zip": "string",
"cross-street": "string",
"special-instructions": "string",
"longitude": "string",
"latitude": "string"
},
"info": {
"scheduled-dt": "string",
"estimated-dt": "string",
"confirmation-number": "string",
"service-type": "string",
"payment-is-cash": "string",
"tip-payment-is-cash": "string",
"payment-type": "string",
"tip-payment-type": "string",
"subtotal": "string",
"delivery-charge": "string",
"sales-tax": "string",
"tip": "string",
"total": "string",
"coupon-description": "string",
"coupon-amount": "string"
},
"restaurant": {
"name": "string",
"billing-comment": "string"
},
"items": [
{
"name": "string",
"group_name": "string",
"group_id": "string",
"pos_id": "string",
"quantity": "string",
"price": "string",
"mods": [
{

                "name": "string",
                "pos_id": "string",
                "portion": "string",
                "group_name": "string",
                "group_id": "string",
                "price": "string",
                "quantity": "string"
            }
        ]
    }
]

}`

The current associations are as follows:

  • Order has one Restaurant
  • Restaurant belongs to Order
  • Order has one Customer
  • Customer belongs to Order
  • Order has one Info
  • Info belongs to Order
  • Order has many Items
  • Items belong to Order
  • Items has many Mods
  • Mods belongs to Items

so far I can post individually to all. But they do not associate.

How would I post the entire object into one route, say "create-order".

And then be able to find order info via orders/1/info/ for instance.

I am very new to node, and I am deeply over my head.

Any help would be a blessing.

I am using sequelize, express, and of course, epilogue

I am in need of a similar feature...
For POST but also for GET. Basically I assume if the user request an object, I want to get all associated data with one request. Doing multiple request should not be required...

The only way I found so far is to modify epilogue to use sequelize "include" options.
Currently working on a pull request...