dchester / epilogue

Create flexible REST endpoints and controllers from Sequelize models in your Express app
846 stars 116 forks source link

How to post a mutli-tiered json object? #192

Open mgudesblatart opened 7 years ago

mgudesblatart commented 7 years ago

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:

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

asmodehn commented 7 years ago

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

asmodehn commented 7 years ago

https://github.com/dchester/epilogue/pull/193