1

I am trying to post a multitiered object to an epilogue generated REST sever with many associated models.

The object:

{
"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.

0 Answers0